Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
olliesilvester committed Sep 17, 2024
1 parent 33b1666 commit 6d953f3
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
9 changes: 0 additions & 9 deletions src/mx_bluesky/hyperion/parameters/gridscan.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ class GridCommon(
)
selected_aperture: ApertureValue | None = Field(default=ApertureValue.SMALL)

# @model_validator(mode="wrap")
# @classmethod
# def set_default_feature_flags(cls, values, handler) -> Any:
# if "use_panda" not in values:
# values["use_panda"] = cls.features.best_effort().use_panda_for_gridscan
# if "use_gpu" not in values:
# values["use_gpu"] = cls.features.best_effort().use_gpu_for_gridscan
# return values

@model_validator(mode="before")
@classmethod
def set_default_feature_flags(cls, values) -> Any:
Expand Down
11 changes: 11 additions & 0 deletions tests/unit_tests/hyperion/parameters/test_parameter_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,14 @@ def test_selected_aperture_uses_default():
raw_params["selected_aperture"] = None
params = RotationScan(**raw_params)
assert params.selected_aperture == ApertureValue.LARGE


def test_feature_flags_overriden_if_supplied(minimal_3d_gridscan_params):
test_params = ThreeDGridScan(**minimal_3d_gridscan_params)
assert test_params.use_panda is False
assert test_params.use_gpu is False
minimal_3d_gridscan_params["use_panda"] = True
minimal_3d_gridscan_params["use_gpu"] = True
test_params = ThreeDGridScan(**minimal_3d_gridscan_params)
assert test_params.use_gpu
assert test_params.use_panda

0 comments on commit 6d953f3

Please sign in to comment.