Skip to content

Commit

Permalink
local tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
ktactac-ornl committed Jun 12, 2024
1 parent c96867f commit eb0d128
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
17 changes: 12 additions & 5 deletions src/imars3d/backend/dataio/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
3 changes: 2 additions & 1 deletion tests/unit/backend/dataio/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/backend/diagnostics/test_tilt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit eb0d128

Please sign in to comment.