From eb0d1287e3c423c602ac3f1ad684a3b1c013a61f Mon Sep 17 00:00:00 2001 From: "Kevin A. Tactac" Date: Wed, 12 Jun 2024 10:24:28 -0400 Subject: [PATCH] local tests pass --- src/imars3d/backend/dataio/data.py | 17 ++++++++++++----- tests/unit/backend/dataio/test_data.py | 3 ++- tests/unit/backend/diagnostics/test_tilt.py | 2 +- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/imars3d/backend/dataio/data.py b/src/imars3d/backend/dataio/data.py index 4bff10f2..d3d4bc21 100644 --- a/src/imars3d/backend/dataio/data.py +++ b/src/imars3d/backend/dataio/data.py @@ -59,14 +59,21 @@ class Foldernames(param.Foldername): * any of the paths searched by resolve_dir_path() (if search_paths is None). """ + def _validate(self, val): + + if isinstance(val, (list, tuple)): + for v in val: + super()._validate(v) + else: + super()._validate(val) + def _resolve(self, paths): - if isinstance(paths, (str, Path)): - return super()._resolve(paths) - elif isinstance(paths, (list, tuple)): + + if isinstance(paths, (list, tuple)): return [self._resolve(path) for path in paths] else: - name = next(x for x in [self.name, self.label, "Foldernames parameter"] if x) - raise ValueError(f"{name} must be a string or a list of strings") + return super()._resolve(paths) + class load_data(param.ParameterizedFunction): diff --git a/tests/unit/backend/dataio/test_data.py b/tests/unit/backend/dataio/test_data.py index 82cb87b0..efbe04fb 100644 --- a/tests/unit/backend/dataio/test_data.py +++ b/tests/unit/backend/dataio/test_data.py @@ -69,7 +69,8 @@ class TestFoldernames(param.Parameterized): # test wrong input with pytest.raises(ValueError) as e: TestFoldernames(f=open(tmpdir / "temp.txt", "w")) - assert str(e.value) == "f must be a string or a list of strings" + + assert str(e.value) == "Foldernames parameter 'TestFoldernames.f' only take str or pathlib.Path types" # test single directory tf = TestFoldernames(f=str(tmpdir)) assert tf.f == str(tmpdir) diff --git a/tests/unit/backend/diagnostics/test_tilt.py b/tests/unit/backend/diagnostics/test_tilt.py index b73b7200..f2f26ca5 100644 --- a/tests/unit/backend/diagnostics/test_tilt.py +++ b/tests/unit/backend/diagnostics/test_tilt.py @@ -285,7 +285,7 @@ def test_apply_tilt_correction(): def test_tilt_correction(): # error_0: incorrect dimension with pytest.raises(ValueError): - tilt_correction(arrays=np.arange(10), tilt=1.0) + tilt_correction(arrays=np.arange(10)) # make synthetic data size = 100 rot_axis_ideal = get_tilted_rot_axis(0, 0)