Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9eb43ee

Browse filesBrowse files
committed
Fix tests
1 parent b73bf6f commit 9eb43ee
Copy full SHA for 9eb43ee

File tree

2 files changed

+5
-3
lines changed
Filter options

2 files changed

+5
-3
lines changed

‎src/napari_matplotlib/slice.py

Copy file name to clipboardExpand all lines: src/napari_matplotlib/slice.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,20 +58,22 @@ def on_update_layers(self) -> None:
5858
"""
5959
Called when layer selection is updated.
6060
"""
61+
if not len(self.layers):
62+
return
6163
if self.current_dim_name == "x":
6264
max = self._layer.data.shape[-2]
6365
elif self.current_dim_name == "y":
6466
max = self._layer.data.shape[-1]
6567
else:
6668
raise RuntimeError("dim name must be x or y")
67-
self.slice_selector.setRange(0, max)
69+
self.slice_selector.setRange(0, max - 1)
6870

6971
@property
7072
def _slice_width(self) -> int:
7173
"""
7274
Width of the slice being plotted.
7375
"""
74-
return self._layer.data.shape[self.current_dim_index] - 1
76+
return self._layer.data.shape[self.current_dim_index]
7577

7678
@property
7779
def _layer(self) -> napari.layers.Layer:

‎src/napari_matplotlib/tests/test_slice.py

Copy file name to clipboardExpand all lines: src/napari_matplotlib/tests/test_slice.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,6 @@ def test_slice_axes(make_napari_viewer, astronaut_data):
5858
assert widget.current_dim_name == "x"
5959
assert widget.slice_selector.value() == 0
6060
assert widget.slice_selector.minimum() == 0
61-
assert widget.slice_selector.maximum() == data.shape[0]
61+
assert widget.slice_selector.maximum() == data.shape[0] - 1
6262
# x/y are flipped in napari
6363
assert widget._slice_width == data.shape[1]

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.