Source code for est.tests.conftest

from typing import Generator
from typing import Tuple

import h5py
import numpy
import pytest
from ewoksorange.tests.conftest import ewoks_orange_canvas  # noqa F401
from ewoksorange.tests.conftest import qtapp  # noqa F401
from ewoksorange.tests.conftest import raw_ewoks_orange_canvas  # noqa F401
from numpy.typing import ArrayLike
from silx.io.url import DataUrl

from .. import resources
from ..core.types.spectrum import Spectrum
from . import data


[docs] @pytest.fixture() def example_pymca() -> Generator[str, None, None]: with resources.tutorial_workflow("example_pymca.ows") as path: yield str(path)
[docs] @pytest.fixture() def example_larch() -> Generator[str, None, None]: with resources.tutorial_workflow("example_larch.ows") as path: yield str(path)
[docs] @pytest.fixture() def example_bm23() -> Generator[str, None, None]: with resources.tutorial_workflow("example_bm23.ows") as path: yield str(path)
[docs] @pytest.fixture() def filename_cu_from_pymca() -> Generator[str, None, None]: with resources.resource_path("exafs", "EXAFS_Cu.dat") as path: yield str(path)
[docs] @pytest.fixture() def filename_cu_from_larch() -> Generator[str, None, None]: with resources.resource_path("exafs", "cu_rt01.xmu") as path: yield str(path)
[docs] @pytest.fixture() def xas_image_data(tmp_path) -> Tuple[DataUrl, DataUrl, ArrayLike, ArrayLike]: energy, spectra = data.example_spectra(shape=(256, 20, 10)) spectra_path = "/data/NXdata/data" energy_path = "/data/NXdata/energy" filename = str(tmp_path / "myfile.h5") with h5py.File(filename, "a") as f: f[spectra_path] = spectra f[energy_path] = energy spectra_url = DataUrl( file_path=filename, data_path="/data/NXdata/data", scheme="silx" ) channel_url = DataUrl( file_path=filename, data_path="/data/NXdata/energy", scheme="silx" ) return spectra_url, channel_url, energy, spectra
[docs] @pytest.fixture() def spectrum_cu_from_pymca() -> Spectrum: energy, mu = data.example_spectrum("exafs", "EXAFS_Cu.dat") return Spectrum(energy=energy, mu=mu)
[docs] @pytest.fixture() def spectrum_cu_from_larch() -> Spectrum: energy, mu = data.example_spectrum("exafs", "cu_rt01.xmu") return Spectrum(energy=energy, mu=mu)
[docs] @pytest.fixture() def limited_data_spectrum() -> Spectrum: return Spectrum(energy=numpy.array([7.1]), mu=numpy.array([1.1]))
[docs] @pytest.fixture() def hdf5_filename_cu_from_pymca(tmpdir) -> str: return str( resources.generate_resource( "exafs", "EXAFS_Cu.dat", word="L", output_directory=str(tmpdir) ) )