Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dstansby committed Aug 23, 2023
1 parent b73bf6f commit 9eb43ee
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions src/napari_matplotlib/slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,20 +58,22 @@ def on_update_layers(self) -> None:
"""
Called when layer selection is updated.
"""
if not len(self.layers):
return
if self.current_dim_name == "x":
max = self._layer.data.shape[-2]
elif self.current_dim_name == "y":
max = self._layer.data.shape[-1]
else:
raise RuntimeError("dim name must be x or y")
self.slice_selector.setRange(0, max)
self.slice_selector.setRange(0, max - 1)

@property
def _slice_width(self) -> int:
"""
Width of the slice being plotted.
"""
return self._layer.data.shape[self.current_dim_index] - 1
return self._layer.data.shape[self.current_dim_index]

@property
def _layer(self) -> napari.layers.Layer:
Expand Down
2 changes: 1 addition & 1 deletion src/napari_matplotlib/tests/test_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,6 @@ def test_slice_axes(make_napari_viewer, astronaut_data):
assert widget.current_dim_name == "x"
assert widget.slice_selector.value() == 0
assert widget.slice_selector.minimum() == 0
assert widget.slice_selector.maximum() == data.shape[0]
assert widget.slice_selector.maximum() == data.shape[0] - 1
# x/y are flipped in napari
assert widget._slice_width == data.shape[1]

0 comments on commit 9eb43ee

Please sign in to comment.