Skip to content

Commit 4f84a7e

Browse files
authored
Merge pull request #181 from bluesky/int-product
Remove `Repeat` in favour of `Product`
2 parents c3791b2 + 42f29b6 commit 4f84a7e

File tree

11 files changed

+197
-158
lines changed

11 files changed

+197
-158
lines changed

docs/conf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
("py:class", "scanspec.core.C"),
7575
("py:class", "scanspec.core.T"),
7676
("py:class", "pydantic.config.ConfigDict"),
77+
("py:class", "numpy.float64"),
7778
]
7879

7980
# Both the class’ and the __init__ method’s docstring are concatenated and

docs/explanations/technical-terms.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ documentation. Consider a 1D line scan:
1313
Axis
1414
----
1515

16-
A fixed reference that can be scanned, i.e. a motor or the `frame_` `DURATION`.
16+
A fixed reference that can be scanned, i.e. a motor.
1717
In the diagram above, the Axis is ``x``. `Spec.axes` will return the Axes that
1818
should be scanned for a given Spec.
1919

docs/how-to/iterate-a-spec.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ If you need to do a fly scan
3030

3131
If you are conducting a fly scan then you need the frames that the motor moves
3232
through. You can get that from the lower and upper bounds of each point. If the
33-
scan is small enough to fit in memory on the machine you can use the `Fly(spec).frames()`
33+
scan is small enough to fit in memory on the machine you can use the `Spec.frames`
3434
method to produce a single `Dimension` object containing the entire scan:
3535

3636
>>> from scanspec.specs import Fly

docs/how-to/serialize-a-spec.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Lets start with an example `Spec`.
1111
This Spec has a `repr` that shows its parameters it was instantiated with:
1212

1313
>>> spec
14-
Product(outer=Line(axis='y', start=4.0, stop=5.0, num=6), inner=Line(axis='x', start=1.0, stop=2.0, num=3))
14+
Product(outer=Line(axis='y', start=4.0, stop=5.0, num=6), inner=Line(axis='x', start=1.0, stop=2.0, num=3), gap=True)
1515

1616

1717
How to Serialize
@@ -20,12 +20,12 @@ How to Serialize
2020
We can recursively serialize it to a dictionary:
2121

2222
>>> spec.serialize()
23-
{'outer': {'axis': 'y', 'start': 4.0, 'stop': 5.0, 'num': 6, 'type': 'Line'}, 'inner': {'axis': 'x', 'start': 1.0, 'stop': 2.0, 'num': 3, 'type': 'Line'}, 'type': 'Product'}
23+
{'outer': {'axis': 'y', 'start': 4.0, 'stop': 5.0, 'num': 6, 'type': 'Line'}, 'inner': {'axis': 'x', 'start': 1.0, 'stop': 2.0, 'num': 3, 'type': 'Line'}, 'gap': True, 'type': 'Product'}
2424

2525
How to Deserialize
2626
------------------
2727

2828
We can turn this back into a spec using `Spec.deserialize`:
2929

3030
>>> Spec.deserialize({'outer': {'axis': 'y', 'start': 4.0, 'stop': 5.0, 'num': 6, 'type': 'Line'}, 'inner': {'axis': 'x', 'start': 1.0, 'stop': 2.0, 'num': 3, 'type': 'Line'}, 'type': 'Product'})
31-
Product(outer=Line(axis='y', start=4.0, stop=5.0, num=6), inner=Line(axis='x', start=1.0, stop=2.0, num=3))
31+
Product(outer=Line(axis='y', start=4.0, stop=5.0, num=6), inner=Line(axis='x', start=1.0, stop=2.0, num=3), gap=True)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ commands =
105105
pre-commit: pre-commit run --all-files --show-diff-on-failure {posargs}
106106
type-checking: pyright src tests {posargs}
107107
tests: pytest --cov=scanspec --cov-report term --cov-report xml:cov.xml {posargs}
108-
docs: sphinx-{posargs:build -E --keep-going} -T docs build/html
108+
docs: sphinx-{posargs:build -EW --keep-going} -T docs build/html
109109
"""
110110

111111
[tool.ruff]

schema.json

Lines changed: 72 additions & 60 deletions
Large diffs are not rendered by default.

src/scanspec/core.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,9 @@ def _make_schema(
268268
return {member.__name__: handler(member) for member in members}
269269

270270

271-
def if_instance_do(x: C, cls: type[C], func: Callable[[C], T]) -> T:
271+
def if_instance_do(
272+
x: C, cls: type[C] | tuple[type[C], Any], func: Callable[[C], T]
273+
) -> T:
272274
"""If x is of type cls then return func(x), otherwise return NotImplemented.
273275
274276
Used as a helper when implementing operator overloading.
@@ -311,7 +313,7 @@ def __len__(self) -> int:
311313
def axes(self) -> list[Axis]:
312314
"""The axes which will move during the scan.
313315
314-
These will be present in `midpoints`, `lower` and `upper`.
316+
These will be present in ``midpoints``, ``lower`` and ``upper``.
315317
"""
316318
return list(self.midpoints.keys())
317319

src/scanspec/service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,5 +396,6 @@ def scanspec_schema_text() -> str:
396396
openapi_version=app.openapi_version,
397397
description=app.description,
398398
routes=app.routes,
399-
)
399+
),
400+
indent=4,
400401
)

0 commit comments

Comments
 (0)