Skip to content

Commit

Permalink
fix: valueError also if no fov in GridWidthHeight (#142)
Browse files Browse the repository at this point in the history
* fix: ValueError also for GridWidthHeight

* ci(dependabot): bump actions/checkout from 3 to 4 (#134)

Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* refactor: remove __str__ method on MDASequence (#136)

* test: add napari-micromanager test (#139)

* test: add napari-micro test

* ci: fix deps

* test: fix

---------

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Talley Lambert <[email protected]>
  • Loading branch information
3 people authored Sep 26, 2023
1 parent a269e66 commit 6d669ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/useq/_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,13 +188,15 @@ def _ncolumns(self, dx: float) -> int:
def num_positions(self) -> int:
"""Return the number of individual positions in the grid.
Note: For GridFromEdges, this will depend on field of view size. If no
field of view size is provided, the number of positions will be 1.
Note: For GridFromEdges and GridWidthHeight, this will depend on field of view
size. If no field of view size is provided, the number of positions will be 1.
"""
if not self.is_relative and (self.fov_width is None or self.fov_height is None):
if isinstance(self, (GridFromEdges, GridWidthHeight)) and (
self.fov_width is None or self.fov_height is None
):
raise ValueError(
"Retrieving the number of positions in a GridFromEdges plan requires "
"that the field of view size be set."
"Retrieving the number of positions in a GridFromEdges or "
"GridWidthHeight plan requires the field of view size to be set."
)

dx, dy = self._step_size(self.fov_width or 1, self.fov_height or 1)
Expand Down
5 changes: 4 additions & 1 deletion tests/test_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,12 @@ def test_grid_type():


def test_num_position_error() -> None:
with pytest.raises(ValueError, match="the field of view size be set"):
with pytest.raises(ValueError, match="plan requires the field of view size"):
GridFromEdges(top=1, left=-1, bottom=-1, right=2).num_positions()

with pytest.raises(ValueError, match="plan requires the field of view size"):
GridWidthHeight(width=2, height=2).num_positions()


expected_rectangle = [(0.2, 1.1), (0.4, 0.2), (-0.3, 0.7)]
expected_ellipse = [(-0.0, -2.1), (0.7, 1.7), (-1.0, 1.3)]
Expand Down

0 comments on commit 6d669ba

Please sign in to comment.