Skip to content

Commit

Permalink
Convert Lists to Sets
Browse files Browse the repository at this point in the history
  • Loading branch information
keithralphs committed Jul 10, 2024
1 parent 19ce1c5 commit afaf658
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
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
17 changes: 8 additions & 9 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,13 +34,12 @@ 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,
}
)
plan_args = {

Check warning on line 37 in src/dls_bluesky_core/plans/wrapped.py

View check run for this annotation

Codecov / codecov/patch

src/dls_bluesky_core/plans/wrapped.py#L37

Added line #L37 was not covered by tests
# If bp.count added delay to plan_args, we could remove all md handling
"detectors": set(map(repr, detectors)),
"num": num,
"delay": delay,
}

_md = {
"plan_args": plan_args,
Expand Down
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

0 comments on commit afaf658

Please sign in to comment.