Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tlambert03 committed Jul 7, 2024
1 parent 11b3912 commit eff659e
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
6 changes: 5 additions & 1 deletion src/useq/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
GridRowsColumns,
GridWidthHeight,
MultiPointPlan,
OrderMode,
RandomPoints,
RelativeMultiPointPlan,
Shape,
)
from useq._hardware_autofocus import AnyAutofocusPlan, AutoFocusPlan, AxesBasedAF
from useq._mda_event import MDAEvent, PropertyTuple
Expand Down Expand Up @@ -54,13 +56,15 @@
"MDASequence",
"MultiPhaseTimePlan",
"MultiPointPlan",
"OrderMode",
"Position", # alias for AbsolutePosition
"PropertyTuple",
"RandomPoints",
"register_well_plates",
"registered_well_plate_keys",
"RelativeMultiPointPlan",
"RelativePosition",
"Shape",
"TDurationLoops",
"TIntervalDuration",
"TIntervalLoops",
Expand Down Expand Up @@ -89,7 +93,7 @@ def __getattr__(name: str) -> Any:
# )

return GridRowsColumns
if name == "AnyGridPlan":
if name == "AnyGridPlan": # pragma: no cover
warnings.warn(
"useq.AnyGridPlan has been renamed to useq.MultiPointPlan",
DeprecationWarning,
Expand Down
29 changes: 27 additions & 2 deletions tests/test_grid.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Iterable, Optional
from typing import TYPE_CHECKING, Iterable, Optional, get_args

import pytest

from useq import GridFromEdges, GridRowsColumns, GridWidthHeight, RandomPoints
from useq import (
GridFromEdges,
GridRowsColumns,
GridWidthHeight,
RandomPoints,
RelativeMultiPointPlan,
RelativePosition,
)
from useq._grid import OrderMode, _rect_indices, _spiral_indices

if TYPE_CHECKING:
Expand Down Expand Up @@ -147,3 +154,21 @@ def test_random_points(n_points: int, shape: str, seed: Optional[int]) -> None:
else:
with pytest.raises(UserWarning, match="Unable to generate"):
list(rp)


fov = {"fov_height": 200, "fov_width": 200}


@pytest.mark.parametrize(
"obj",
[
GridRowsColumns(rows=1, columns=2, **fov),
GridWidthHeight(width=10, height=10, **fov),
RandomPoints(num_points=10, **fov),
RelativePosition(**fov),
],
)
def test_points_plans(obj: RelativeMultiPointPlan):
assert isinstance(obj, get_args(RelativeMultiPointPlan))
assert all(isinstance(x, RelativePosition) for x in obj)
assert isinstance(obj.num_positions(), int)

0 comments on commit eff659e

Please sign in to comment.