From 0a1f7255bdf52c46a5d40b474d7612b73d7a0044 Mon Sep 17 00:00:00 2001 From: domna Date: Sat, 24 Oct 2026 08:47:40 +0200 Subject: [PATCH 1/2] Fix error in tests --- tests/test_TiO2.py | 12 ++++++------ tests/test_dispersions.py | 14 ++++++-------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/tests/test_TiO2.py b/tests/test_TiO2.py index 95b115d1..f591587d 100644 --- a/tests/test_TiO2.py +++ b/tests/test_TiO2.py @@ -14,7 +14,7 @@ @fixture -def datadir(tmpdir, request): +def datadir(tmp_path, request): """ Fixture responsible for searching a folder with the same name of test module and, if available, moving all contents to a temporary directory so @@ -24,17 +24,17 @@ def datadir(tmpdir, request): test_dir, _ = os.path.splitext(filename) if os.path.isdir(test_dir): - rmtree(tmpdir) - copytree(test_dir, str(tmpdir)) + rmtree(tmp_path) + copytree(test_dir, str(tmp_path)) - return tmpdir + return tmp_path @fixture def meas_data(datadir): """Fixture for getting the reference measurement data from the file.""" return ( - elli.read_spectraray_rho(datadir.join("TiO2_400cycles.txt")) + elli.read_spectraray_rho(datadir / "TiO2_400cycles.txt") .loc[70.06] .loc[400:800] ) @@ -43,7 +43,7 @@ def meas_data(datadir): @fixture def si_dispersion(datadir): """Fixture to load the silicon dispersion from file.""" - sr = elli.TableSpectraRay(datadir) + sr = elli.TableSpectraRay(f"{datadir}{os.sep}") silicon = elli.IsotropicMaterial(sr.load_dispersion_table(f"{os.sep}Si_Aspnes.mat")) return silicon diff --git a/tests/test_dispersions.py b/tests/test_dispersions.py index c111c126..58f82562 100644 --- a/tests/test_dispersions.py +++ b/tests/test_dispersions.py @@ -16,16 +16,16 @@ @fixture -def datadir(tmpdir, request): +def datadir(tmp_path, request): """Fixture for providing the dispersion prototype folder""" filename = request.module.__file__ test_dir, _ = os.path.splitext(filename) if os.path.isdir(test_dir): - rmtree(tmpdir) - copytree(test_dir, str(tmpdir)) + rmtree(tmp_path) + copytree(test_dir, str(tmp_path)) - return tmpdir + return tmp_path def test_constant_refr_index(): @@ -68,7 +68,7 @@ def test_regression_dispersions_default(datadir): lbda = np.linspace(400, 1000, 500) for dispersion in dispersions: - prototype = pd.read_csv(datadir.join(f"{dispersion}_default.csv"), index_col=0) + prototype = pd.read_csv(datadir / f"{dispersion}_default.csv", index_col=0) disp = elli.DispersionFactory.get_dispersion(dispersion) assert_frame_equal(prototype, disp.get_dielectric_df(lbda)) @@ -196,9 +196,7 @@ def test_regression_dispersions_custom_values(datadir): for dispersion in dispersions: disp_name = dispersion.get("name") - prototype = pd.read_csv( - datadir.join(f"{disp_name}_custom_values.csv"), index_col=0 - ) + prototype = pd.read_csv(datadir / f"{disp_name}_custom_values.csv", index_col=0) disp = elli.DispersionFactory.get_dispersion( disp_name, **dispersion.get("single_params") ) From d7ea7025cd47591417443129131d2c20423e4f7c Mon Sep 17 00:00:00 2001 From: domna Date: Sat, 24 Oct 2026 08:48:57 +0200 Subject: [PATCH 2/2] ruff formatting --- tests/test_TiO2.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/test_TiO2.py b/tests/test_TiO2.py index f591587d..6d586fab 100644 --- a/tests/test_TiO2.py +++ b/tests/test_TiO2.py @@ -34,9 +34,7 @@ def datadir(tmp_path, request): def meas_data(datadir): """Fixture for getting the reference measurement data from the file.""" return ( - elli.read_spectraray_rho(datadir / "TiO2_400cycles.txt") - .loc[70.06] - .loc[400:800] + elli.read_spectraray_rho(datadir / "TiO2_400cycles.txt").loc[70.06].loc[400:800] )