Skip to content

Fix slicing 2D images #205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Explcitly check dimensions in slice tests
  • Loading branch information
dstansby committed Aug 23, 2023
commit 726b66aca1ba56a690264501e75272258211dbad
4 changes: 3 additions & 1 deletion src/napari_matplotlib/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import os
from pathlib import Path
from typing import Any, Dict, Tuple

import numpy as np
import numpy.typing as npt
import pytest
from skimage import data

Expand All @@ -18,7 +20,7 @@ def image_data(request):


@pytest.fixture
def astronaut_data():
def astronaut_data() -> Tuple[npt.NDArray[Any], Dict[Any, Any]]:
return data.astronaut(), {"rgb": True}


Expand Down
8 changes: 8 additions & 0 deletions src/napari_matplotlib/tests/test_slice.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@
def test_slice_3D(make_napari_viewer, brain_data):
viewer = make_napari_viewer()
viewer.theme = "light"

data = brain_data[0]
assert data.ndim == 3
viewer.add_image(brain_data[0], **brain_data[1])

axis = viewer.dims.last_used
slice_no = brain_data[0].shape[0] - 1
viewer.dims.set_current_step(axis, slice_no)
Expand All @@ -23,7 +27,11 @@ def test_slice_3D(make_napari_viewer, brain_data):
def test_slice_2D(make_napari_viewer, astronaut_data):
viewer = make_napari_viewer()
viewer.theme = "light"

data = astronaut_data[0]
assert data.ndim == 2
viewer.add_image(astronaut_data[0], **astronaut_data[1])

fig = SliceWidget(viewer).figure
# Need to return a copy, as original figure is too eagerley garbage
# collected by the widget
Expand Down