Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions tests/test_TiO2.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -24,26 +24,24 @@ 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"))
.loc[70.06]
.loc[400:800]
elli.read_spectraray_rho(datadir / "TiO2_400cycles.txt").loc[70.06].loc[400:800]
)


@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
Expand Down
14 changes: 6 additions & 8 deletions tests/test_dispersions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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")
)
Expand Down
Loading