Skip to content

Commit ce64fca

Browse files
authored
Merge branch 'main' into paul/fix-contrast-limits
2 parents 6a18523 + 64edb23 commit ce64fca

File tree

14 files changed

+206
-55
lines changed

14 files changed

+206
-55
lines changed

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
version: 2
3+
updates:
4+
- package-ecosystem: "github-actions"
5+
directory: "/"
6+
schedule:
7+
interval: "monthly"
8+
groups:
9+
github-actions:
10+
patterns:
11+
- "*"

.github/workflows/docs.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: Build docs
2+
permissions:
3+
contents: read
24

35
on:
46

@@ -17,13 +19,15 @@ jobs:
1719
name: Build & Upload Artifact
1820
runs-on: ubuntu-latest
1921
steps:
20-
- uses: actions/checkout@v3
22+
- uses: actions/checkout@v4
23+
with:
24+
persist-credentials: false
2125

22-
- uses: actions/setup-python@v3
26+
- uses: actions/setup-python@v5
2327
with:
2428
python-version: "3.10"
2529

26-
- uses: tlambert03/setup-qt-libs@v1
30+
- uses: tlambert03/setup-qt-libs@19e4ef2d781d81f5f067182e228b54ec90d23b76 # v1
2731

2832
- name: Install Dependencies
2933
run: |
@@ -32,13 +36,13 @@ jobs:
3236
sudo apt install graphviz --yes
3337
3438
- name: Build Docs
35-
uses: aganders3/headless-gui@v2
39+
uses: aganders3/headless-gui@f85dd6316993505dfc5f21839d520ae440c84816 # v2
3640
with:
3741
run: make html
3842
working-directory: ./docs
3943

4044
- name: Upload artifact
41-
uses: actions/upload-artifact@v3
45+
uses: actions/upload-artifact@v4
4246
with:
4347
name: docs
4448
path: docs/_build
@@ -49,13 +53,15 @@ jobs:
4953
needs: build-docs
5054
if: contains(github.ref, 'tags')
5155
steps:
52-
- uses: actions/checkout@v3
53-
- uses: actions/download-artifact@v3
56+
- uses: actions/checkout@v4
57+
with:
58+
persist-credentials: false
59+
- uses: actions/[email protected]
5460
with:
5561
name: docs
5662

5763
- name: Push to GitHub pages
58-
uses: JamesIves/github-pages-deploy-action@v4
64+
uses: JamesIves/github-pages-deploy-action@6c2d9db40f9296374acc17b90404b6e8864128c8 # v4
5965
with:
6066
folder: html
6167
ssh-key: ${{ secrets.DEPLOY_KEY }}

.github/workflows/test_and_deploy.yml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
name: tests
2+
permissions:
3+
contents: read
24

35
on:
46
push:
@@ -17,6 +19,19 @@ concurrency:
1719
cancel-in-progress: true
1820

1921
jobs:
22+
pre-commit:
23+
name: precommit
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
27+
with:
28+
fetch-depth: 0
29+
- uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.5.0
30+
with:
31+
python-version: "3.x"
32+
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
33+
with:
34+
extra_args: --hook-stage manual --all-files
2035
test:
2136
name: ${{ matrix.platform }} py${{ matrix.python-version }}
2237
runs-on: ${{ matrix.platform }}
@@ -27,15 +42,17 @@ jobs:
2742
python-version: ['3.10', '3.11', '3.12']
2843

2944
steps:
30-
- uses: actions/checkout@v3
45+
- uses: actions/checkout@v4
46+
with:
47+
persist-credentials: false
3148

3249
- name: Set up Python ${{ matrix.python-version }}
33-
uses: actions/setup-python@v3
50+
uses: actions/setup-python@v5
3451
with:
3552
python-version: ${{ matrix.python-version }}
3653

3754
# these libraries enable testing on Qt on linux
38-
- uses: tlambert03/setup-qt-libs@v1
55+
- uses: tlambert03/setup-qt-libs@19e4ef2d781d81f5f067182e228b54ec90d23b76 # v1
3956

4057
# strategy borrowed from vispy for installing opengl libs on windows
4158
- name: Install Windows OpenGL
@@ -54,15 +71,15 @@ jobs:
5471
run: python -m tox
5572

5673
- name: Upload pytest test results
57-
uses: actions/upload-artifact@v3
74+
uses: actions/upload-artifact@v4
5875
with:
5976
name: pytest-results-${{ matrix.platform }} py${{ matrix.python-version }}
6077
path: reports/
6178
# Use always() to always run this step to publish test results when there are test failures
6279
if: ${{ always() }}
6380

6481
- name: Coverage
65-
uses: codecov/codecov-action@v4
82+
uses: codecov/codecov-action@18283e04ce6e62d37312384ff67231eb8fd56d24 # v5
6683
# Don't run coverage on merge queue CI to avoid duplicating reports
6784
# to codecov. See https://github.com/matplotlib/napari-matplotlib/issues/155
6885
if: github.event_name != 'merge_group'
@@ -83,9 +100,11 @@ jobs:
83100
permissions:
84101
id-token: write
85102
steps:
86-
- uses: actions/checkout@v2
103+
- uses: actions/checkout@v4
104+
with:
105+
persist-credentials: false
87106
- name: Set up Python
88-
uses: actions/setup-python@v2
107+
uses: actions/setup-python@v5
89108
with:
90109
python-version: "3.x"
91110
- name: Install build
@@ -99,4 +118,4 @@ jobs:
99118
python -m build .
100119
101120
- name: Publish package
102-
uses: pypa/gh-action-pypi-publish@release/v1
121+
uses: pypa/gh-action-pypi-publish@76f52bc884231f62b9a034ebfe128415bbaabdfc # v1.12.4

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
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.0
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.4.2'
27+
rev: 'v0.11.9'
2828
hooks:
2929
- id: ruff
3030

README.md

Lines changed: 1 addition & 1 deletion
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

docs/changelog.rst

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,30 @@
11
Changelog
22
=========
3+
4+
2.1.0
5+
-----
6+
New features
7+
~~~~~~~~~~~~
8+
- Added a GUI element to manually set the number of bins in the histogram widgets.
9+
10+
2.0.3
11+
-----
12+
Bug fixes
13+
~~~~~~~~~
14+
- Fix an error that happened when the histogram widget was open, but a layer that doesn't support
15+
histogramming (e.g., a labels layer) was selected.
16+
317
2.0.2
418
-----
519
Dependencies
620
~~~~~~~~~~~~
721
napari-matplotlib now adheres to `SPEC 0 <https://scientific-python.org/specs/spec-0000/>`_, and has:
22+
823
- Dropped support for Python 3.9
924
- Added support for Python 3.12
1025
- Added a minimum required numpy verison of 1.23
26+
- Pinned the maximum napari version to ``< 0.5``.
27+
Version 3.0 of ``napari-matplotlib`` will introduce support for ``napari`` version 0.5.
1128

1229
2.0.1
1330
-----

pyproject.toml

Lines changed: 13 additions & 7 deletions
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

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

src/napari_matplotlib/base.py

Lines changed: 15 additions & 8 deletions
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

@@ -224,14 +224,24 @@ def _setup_callbacks(self) -> None:
224224
self._update_layers
225225
)
226226

227+
@property
228+
def _valid_layer_selection(self) -> bool:
229+
"""
230+
Return `True` if layer selection is valid.
231+
"""
232+
return self.n_selected_layers in self.n_layers_input and all(
233+
isinstance(layer, self.input_layer_types) for layer in self.layers
234+
)
235+
227236
def _update_layers(self, event: napari.utils.events.Event) -> None:
228237
"""
229238
Update the ``layers`` attribute with currently selected layers and re-draw.
230239
"""
231240
self.layers = list(self.viewer.layers.selection)
232241
self.layers = sorted(self.layers, key=lambda layer: layer.name)
233242
self.on_update_layers()
234-
self._draw()
243+
if self._valid_layer_selection:
244+
self._draw()
235245

236246
def _draw(self) -> None:
237247
"""
@@ -243,10 +253,7 @@ def _draw(self) -> None:
243253
with mplstyle.context(self.napari_theme_style_sheet):
244254
# everything should be done in the style context
245255
self.clear()
246-
if self.n_selected_layers in self.n_layers_input and all(
247-
isinstance(layer, self.input_layer_types)
248-
for layer in self.layers
249-
):
256+
if self._valid_layer_selection:
250257
self.draw()
251258
self.canvas.draw() # type: ignore[no-untyped-call]
252259

0 commit comments

Comments
 (0)