Skip to content

Commit 7e860f5

Browse files
Support napari>=0.5 (#274)
* Remove as_dict kwarg * Pin to napari >= 0.5 * Fix scatter test? * Update test image * Fix brain data * Fix another as_dict arg * Fix FutureWarning * Fix scatter test's OverflowError And revert to original baseline images. * Try updating mypy's python version. * Revert shape → newshape and suppress deprecation warning. --------- Co-authored-by: Sam Cunliffe <[email protected]> Co-authored-by: Sam Cunliffe <[email protected]>
1 parent d0b03bb commit 7e860f5

File tree

5 files changed

+22
-14
lines changed

5 files changed

+22
-14
lines changed

pyproject.toml

+13-7
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,18 @@ filterwarnings = [
1313
"ignore:distutils Version classes are deprecated:DeprecationWarning",
1414
"ignore:`np.bool8` is a deprecated alias for `np.bool_`:DeprecationWarning",
1515
# Coming from pydantic via napari
16-
"ignore:Pickle, copy, and deepcopy support will be removed from itertools in Python 3.14.:DeprecationWarning"
16+
"ignore:Pickle, copy, and deepcopy support will be removed from itertools in Python 3.14.:DeprecationWarning",
17+
# Until we stop supporting older numpy versions (<2.1)
18+
"ignore:(?s).*`newshape` keyword argument is deprecated.*$:DeprecationWarning",
1719
]
1820
qt_api = "pyqt6"
19-
addopts = ["--mpl", "--mpl-baseline-relative", "--strict-config", "--strict-markers", "-ra"]
21+
addopts = [
22+
"--mpl",
23+
"--mpl-baseline-relative",
24+
"--strict-config",
25+
"--strict-markers",
26+
"-ra",
27+
]
2028
minversion = "7"
2129
testpaths = ["src/napari_matplotlib/tests"]
2230
log_cli_level = "INFO"
@@ -54,17 +62,15 @@ ignore = [
5462
convention = "numpy"
5563

5664
[tool.mypy]
57-
python_version = "3.10"
65+
python_version = "3.12"
5866
# Block below are checks that form part of mypy 'strict' mode
5967
strict = true
6068
disallow_subclassing_any = false # TODO: fix
61-
warn_return_any = false # TODO: fix
69+
warn_return_any = false # TODO: fix
6270
ignore_missing_imports = true
6371

6472
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
6573

6674
[[tool.mypy.overrides]]
67-
module = [
68-
"napari_matplotlib/tests/*",
69-
]
75+
module = ["napari_matplotlib/tests/*"]
7076
disallow_untyped_defs = false

setup.cfg

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ project_urls =
2828
packages = find:
2929
install_requires =
3030
matplotlib
31-
napari<0.5
31+
napari>=0.5
3232
numpy>=1.23
3333
tinycss2
3434
python_requires = >=3.10

src/napari_matplotlib/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def __init__(
4242
super().__init__(parent=parent)
4343
self.viewer = napari_viewer
4444
self.napari_theme_style_sheet = style_sheet_from_theme(
45-
get_theme(napari_viewer.theme, as_dict=False)
45+
get_theme(napari_viewer.theme)
4646
)
4747

4848
# Sets figure.* style
@@ -84,7 +84,7 @@ def _on_napari_theme_changed(self, event: Event) -> None:
8484
Event that triggered the callback.
8585
"""
8686
self.napari_theme_style_sheet = style_sheet_from_theme(
87-
get_theme(event.value, as_dict=False)
87+
get_theme(event.value)
8888
)
8989
self._replace_toolbar_icons()
9090

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

src/napari_matplotlib/tests/scatter/test_scatter.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ def test_scatter_2D(make_napari_viewer, astronaut_data):
1515
viewer.add_image(astronaut_data[0], **astronaut_data[1], name="astronaut")
1616

1717
viewer.add_image(
18-
astronaut_data[0] * -1, **astronaut_data[1], name="astronaut_reversed"
18+
astronaut_data[0] * -1.0,
19+
**astronaut_data[1],
20+
name="astronaut_reversed",
1921
)
2022
# De-select existing selection
2123
viewer.layers.selection.clear()
@@ -36,7 +38,7 @@ def test_scatter_3D(make_napari_viewer, brain_data):
3638
viewer.add_image(brain_data[0], **brain_data[1], name="brain")
3739

3840
viewer.add_image(
39-
brain_data[0] * -1, **brain_data[1], name="brain_reversed"
41+
brain_data[0] * -1.0, **brain_data[1], name="brain_reversed"
4042
)
4143
# De-select existing selection
4244
viewer.layers.selection.clear()

src/napari_matplotlib/tests/test_theme.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def _mock_up_theme() -> None:
2929
Based on:
3030
https://napari.org/stable/gallery/new_theme.html
3131
"""
32-
blue_theme = napari.utils.theme.get_theme("dark", False)
32+
blue_theme = napari.utils.theme.get_theme("dark")
3333
blue_theme.label = "blue"
3434
blue_theme.background = "#4169e1" # my favourite shade of blue
3535
napari.utils.theme.register_theme(

0 commit comments

Comments
 (0)