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

Convert Lists to Sets #18

Merged
merged 2 commits into from
Jul 10, 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
8 changes: 4 additions & 4 deletions src/dls_bluesky_core/plans/scanspec.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import operator
from functools import reduce
from typing import Any, List, Mapping, Optional
from typing import Any, Mapping, Optional

import bluesky.plans as bp
from bluesky.protocols import Movable, Readable
Expand All @@ -17,7 +17,7 @@


def scan(
detectors: List[Readable],
detectors: set[Readable],
axes_to_move: Mapping[str, Movable],
spec: Spec[str],
metadata: Optional[Mapping[str, Any]] = None,
Expand All @@ -26,7 +26,7 @@ def scan(
Scan wrapping `bp.scan_nd`

Args:
detectors: List of readable devices, will take a reading at
detectors: Set of readable devices, will take a reading at
each point
axes_to_move: All axes involved in this scan, names and
objects
Expand All @@ -44,7 +44,7 @@ def scan(

_md = {
"plan_args": {
"detectors": list(map(repr, detectors)),
"detectors": set(map(repr, detectors)),
"axes_to_move": {k: repr(v) for k, v in axes_to_move.items()},
"spec": repr(spec),
},
Expand Down
20 changes: 4 additions & 16 deletions src/dls_bluesky_core/plans/wrapped.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


def count(
detectors: List[Readable],
detectors: set[Readable],
num: int = 1,
delay: Optional[Union[float, List[float]]] = None,
metadata: Optional[Mapping[str, Any]] = None,
Expand All @@ -20,7 +20,7 @@ def count(
Take `n` readings from a device

Args:
detectors (List[Readable]): Readable devices to read
detectors (Set[Readable]): Readable devices to read
num (int, optional): Number of readings to take. Defaults to 1.
delay (Optional[Union[float, List[float]]], optional): Delay between readings.
Defaults to None.
Expand All @@ -34,17 +34,5 @@ def count(
Yields:
Iterator[MsgGenerator]: _description_
"""
plan_args = (
{ # If bp.count added delay to plan_args, we could remove all md handling
"detectors": list(map(repr, detectors)),
"num": num,
"delay": delay,
}
)

_md = {
"plan_args": plan_args,
**(metadata or {}),
}

yield from bp.count(detectors, num, delay=delay, md=_md)

yield from bp.count(detectors, num, delay=delay, md=metadata or {})
4 changes: 2 additions & 2 deletions tests/plans/test_scanspec_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_metadata_of_simple_spec(run_engine, x, loop):
plan_args = start_document["plan_args"]

assert len(plan_args) == 3
assert plan_args["detectors"] == [repr(det)]
assert plan_args["detectors"] == {repr(det)}
assert plan_args["spec"] == repr(spec)
assert plan_args["axes_to_move"] == {
x.name: repr(x),
Expand Down Expand Up @@ -89,7 +89,7 @@ def test_metadata_of_spiral_spec(run_engine, x, y, loop):
plan_args = start_document["plan_args"]

assert len(plan_args) == 3
assert plan_args["detectors"] == [repr(det)]
assert plan_args["detectors"] == {repr(det)}
assert plan_args["spec"] == repr(spec)
assert plan_args["axes_to_move"] == {x.name: repr(x), y.name: repr(y)}

Expand Down
Loading