Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update calls to param's API #300

Merged
merged 6 commits into from
Jun 13, 2024
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
3 changes: 3 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ build:
os: ubuntu-20.04
tools:
python: "mambaforge-4.10"
jobs:
pre_build:
- mkdir ~/tmp

sphinx:
builder: html
Expand Down
4 changes: 2 additions & 2 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ dependencies:
- datashader
- hvplot
# GUI
- panel<1.3
- param<2
- panel
- param
- pyvista
# IO
- dxchange
Expand Down
16 changes: 11 additions & 5 deletions src/imars3d/backend/dataio/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,20 @@ 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
2 changes: 1 addition & 1 deletion src/imars3d/backend/workflow/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def _instrospect_task_function(self, function_str: str) -> namedtuple:
# depending on the value of other parameters. Methods `dryrun()` assume that
# parameters are independent of each other
independent = False if function_name in ["load_data"] else True
outputs = dict(function=f, paramdict=f.params(), params_independent=independent)
outputs = dict(function=f, paramdict=f.param.params(), params_independent=independent)
return namedtuple("TaskFuncionInstrospection", outputs.keys())(**outputs)

def _resolve_inputs(self, task_inputs: dict, paramdict: dict) -> dict:
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
Loading