Skip to content

Support napari>=0.5 #274

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 11 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
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
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ project_urls =
packages = find:
install_requires =
matplotlib
napari<0.5
napari>=0.5
numpy>=1.23
tinycss2
python_requires = >=3.10
Expand Down
6 changes: 3 additions & 3 deletions src/napari_matplotlib/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(
super().__init__(parent=parent)
self.viewer = napari_viewer
self.napari_theme_style_sheet = style_sheet_from_theme(
get_theme(napari_viewer.theme, as_dict=False)
get_theme(napari_viewer.theme)
)

# Sets figure.* style
Expand Down Expand Up @@ -84,7 +84,7 @@ def _on_napari_theme_changed(self, event: Event) -> None:
Event that triggered the callback.
"""
self.napari_theme_style_sheet = style_sheet_from_theme(
get_theme(event.value, as_dict=False)
get_theme(event.value)
)
self._replace_toolbar_icons()

Expand All @@ -97,7 +97,7 @@ def _napari_theme_has_light_bg(self) -> bool:
bool
True if theme's background colour has hsl lighter than 50%, False if darker.
"""
theme = napari.utils.theme.get_theme(self.viewer.theme, as_dict=False)
theme = napari.utils.theme.get_theme(self.viewer.theme)
_, _, bg_lightness = theme.background.as_hsl_tuple()
return bg_lightness > 0.5

Expand Down
2 changes: 1 addition & 1 deletion src/napari_matplotlib/tests/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def fig_to_array(fig: Figure) -> npt.NDArray[np.uint8]:
io_buf.seek(0)
img_arr: npt.NDArray[np.uint8] = np.reshape(
np.frombuffer(io_buf.getvalue(), dtype=np.uint8),
newshape=(int(fig.bbox.bounds[3]), int(fig.bbox.bounds[2]), -1),
shape=(int(fig.bbox.bounds[3]), int(fig.bbox.bounds[2]), -1),
)
return img_arr

Expand Down
6 changes: 4 additions & 2 deletions src/napari_matplotlib/tests/scatter/test_scatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def test_scatter_2D(make_napari_viewer, astronaut_data):
viewer.add_image(astronaut_data[0], **astronaut_data[1], name="astronaut")

viewer.add_image(
astronaut_data[0] * -1, **astronaut_data[1], name="astronaut_reversed"
astronaut_data[0] * -1.0,
**astronaut_data[1],
name="astronaut_reversed",
)
# De-select existing selection
viewer.layers.selection.clear()
Expand All @@ -36,7 +38,7 @@ def test_scatter_3D(make_napari_viewer, brain_data):
viewer.add_image(brain_data[0], **brain_data[1], name="brain")

viewer.add_image(
brain_data[0] * -1, **brain_data[1], name="brain_reversed"
brain_data[0] * -1.0, **brain_data[1], name="brain_reversed"
)
# De-select existing selection
viewer.layers.selection.clear()
Expand Down
2 changes: 1 addition & 1 deletion src/napari_matplotlib/tests/test_theme.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def _mock_up_theme() -> None:
Based on:
https://napari.org/stable/gallery/new_theme.html
"""
blue_theme = napari.utils.theme.get_theme("dark", False)
blue_theme = napari.utils.theme.get_theme("dark")
blue_theme.label = "blue"
blue_theme.background = "#4169e1" # my favourite shade of blue
napari.utils.theme.register_theme(
Expand Down
Loading