Skip to content

Commit a0814f9

Browse files
authored
Merge branch 'main' into contrast_test
2 parents ec8cec1 + bb42586 commit a0814f9

File tree

11 files changed

+41
-33
lines changed

11 files changed

+41
-33
lines changed

.github/workflows/docs.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ jobs:
1717
name: Build & Upload Artifact
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v3
20+
- uses: actions/checkout@v4
2121

22-
- uses: actions/setup-python@v3
22+
- uses: actions/setup-python@v5
2323
with:
2424
python-version: "3.10"
2525

@@ -38,7 +38,7 @@ jobs:
3838
working-directory: ./docs
3939

4040
- name: Upload artifact
41-
uses: actions/upload-artifact@v3
41+
uses: actions/upload-artifact@v4
4242
with:
4343
name: docs
4444
path: docs/_build
@@ -49,8 +49,8 @@ jobs:
4949
needs: build-docs
5050
if: contains(github.ref, 'tags')
5151
steps:
52-
- uses: actions/checkout@v3
53-
- uses: actions/download-artifact@v3
52+
- uses: actions/checkout@v4
53+
- uses: actions/download-artifact@v4.1.7
5454
with:
5555
name: docs
5656

.github/workflows/test_and_deploy.yml

+5-5
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ jobs:
2727
python-version: ['3.10', '3.11', '3.12']
2828

2929
steps:
30-
- uses: actions/checkout@v3
30+
- uses: actions/checkout@v4
3131

3232
- name: Set up Python ${{ matrix.python-version }}
33-
uses: actions/setup-python@v3
33+
uses: actions/setup-python@v5
3434
with:
3535
python-version: ${{ matrix.python-version }}
3636

@@ -54,7 +54,7 @@ jobs:
5454
run: python -m tox
5555

5656
- name: Upload pytest test results
57-
uses: actions/upload-artifact@v3
57+
uses: actions/upload-artifact@v4
5858
with:
5959
name: pytest-results-${{ matrix.platform }} py${{ matrix.python-version }}
6060
path: reports/
@@ -83,9 +83,9 @@ jobs:
8383
permissions:
8484
id-token: write
8585
steps:
86-
- uses: actions/checkout@v2
86+
- uses: actions/checkout@v4
8787
- name: Set up Python
88-
uses: actions/setup-python@v2
88+
uses: actions/setup-python@v5
8989
with:
9090
python-version: "3.x"
9191
- name: Install build

.pre-commit-config.yaml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.6.0
3+
rev: v5.0.0
44
hooks:
55
- id: check-docstring-first
66
- id: end-of-file-fixer
77
- id: trailing-whitespace
88

99
- repo: https://github.com/psf/black-pre-commit-mirror
10-
rev: 24.4.2
10+
rev: 25.1.0
1111
hooks:
1212
- id: black
1313

@@ -17,14 +17,14 @@ repos:
1717
- id: napari-plugin-checks
1818

1919
- repo: https://github.com/pre-commit/mirrors-mypy
20-
rev: v1.10.1
20+
rev: v1.15.0
2121
hooks:
2222
- id: mypy
2323
additional_dependencies: [numpy, matplotlib]
2424

2525
- repo: https://github.com/astral-sh/ruff-pre-commit
2626
# Ruff version.
27-
rev: 'v0.5.1'
27+
rev: 'v0.9.9'
2828
hooks:
2929
- id: ruff
3030

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A plugin to create Matplotlib plots from napari layers
1515
## Introduction
1616
`napari-matplotlib` is a bridge between `napari` and `matplotlib`, making it easy to create publication quality `Matplotlib` plots based on the data loaded in `napari` layers.
1717

18-
Documentaiton can be found at https://napari-matplotlib.github.io/
18+
Documentation can be found at https://napari-matplotlib.github.io/
1919

2020
## Contributing
2121

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/histogram.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
def _get_bins(
2929
data: npt.NDArray[Any],
3030
num_bins: int = 100,
31-
) -> npt.NDArray[Any]:
31+
) -> npt.NDArray[np.floating]:
3232
"""Create evenly spaced bins with a given interval.
3333
3434
Parameters
@@ -161,13 +161,13 @@ def draw(self) -> None:
161161
for i, c in enumerate("rgb"):
162162
self.axes.hist(
163163
data[..., i].ravel(),
164-
bins=bins.tolist(),
164+
bins=bins.tolist(), # type: ignore[arg-type]
165165
label=c,
166166
histtype="step",
167167
color=_COLORS[c],
168168
)
169169
else:
170-
self.axes.hist(data.ravel(), bins=bins.tolist(), label=layer.name)
170+
self.axes.hist(data.ravel(), bins=bins.tolist(), label=layer.name) # type: ignore[arg-type]
171171

172172
self._contrast_lines = [
173173
self.axes.axvline(lim, color="white")
@@ -297,7 +297,7 @@ def draw(self) -> None:
297297

298298
bins = _get_bins(data)
299299

300-
_, bins, patches = self.axes.hist(data, bins=bins.tolist())
300+
_, bins, patches = self.axes.hist(data, bins=bins.tolist()) # type: ignore[arg-type]
301301
patches = cast(BarContainer, patches)
302302

303303
# recolor the histogram plot
Loading

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)