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

Exception for no detectors #333

Merged
merged 5 commits into from
May 24, 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 src/ophyd_async/plan_stubs/fly.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def time_resolved_fly_and_collect_with_static_seq_table(
stages/unstages the devices, and opens and closes the run.

"""
if not detectors:
raise ValueError("No detectors provided. There must be at least one.")

# Set up scan and prepare trigger
deadtime = max(det.controller.get_deadtime(exposure) for det in detectors)
yield from prepare_static_seq_table_flyer_and_detectors_with_same_trigger(
Expand Down
28 changes: 28 additions & 0 deletions tests/plan_stubs/test_fly.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,3 +349,31 @@ def fly():
"stream_datum",
"stop",
]


@pytest.mark.parametrize("detector_list", [[], None])
async def test_at_least_one_detector_in_fly_plan(
RE: RunEngine,
flyer,
detector_list,
):
# Trigger parameters
number_of_frames = 1
exposure = 1
shutter_time = 0.004

assert not detector_list

def fly():
yield from time_resolved_fly_and_collect_with_static_seq_table(
stream_name="stream1",
detectors=detector_list,
flyer=flyer,
number_of_frames=number_of_frames,
exposure=exposure,
shutter_time=shutter_time,
)

with pytest.raises(ValueError) as exc:
RE(fly())
assert str(exc) == "No detectors provided. There must be at least one."
Loading