Skip to content

Commit 5df6b6b

Browse files
committed
Merge branch 'main' into color-histogram-bars
2 parents 5b87710 + 5e59bd3 commit 5df6b6b

21 files changed

+46
-52
lines changed

.github/workflows/test_and_deploy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
fail-fast: false
2121
matrix:
2222
platform: [ubuntu-latest, macos-latest, windows-latest]
23-
python-version: ['3.8', '3.9', '3.10', '3.11']
23+
python-version: ['3.9', '3.10', '3.11']
2424

2525
steps:
2626
- uses: actions/checkout@v3

.pre-commit-config.yaml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v4.5.0
44
hooks:
55
- id: check-docstring-first
66
- id: end-of-file-fixer
@@ -17,14 +17,14 @@ repos:
1717
- id: napari-plugin-checks
1818

1919
- repo: https://github.com/pre-commit/mirrors-mypy
20-
rev: v1.5.1
20+
rev: v1.6.0
2121
hooks:
2222
- id: mypy
23-
additional_dependencies: [numpy, matplotlib<3.8]
23+
additional_dependencies: [numpy, matplotlib]
2424

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

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ profile = "black"
2323
line_length = 79
2424

2525
[tool.ruff]
26-
target-version = "py38"
26+
target-version = "py39"
2727
select = ["I", "UP", "F", "E", "W", "D"]
2828
ignore = [
2929
"D100", # Missing docstring in public module
@@ -45,7 +45,7 @@ fix = true
4545
convention = "numpy"
4646

4747
[tool.mypy]
48-
python_version = "3.8"
48+
python_version = "3.9"
4949
# Block below are checks that form part of mypy 'strict' mode
5050
warn_unused_configs = true
5151
warn_redundant_casts = true

setup.cfg

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ project_urls =
2727
[options]
2828
packages = find:
2929
install_requires =
30-
matplotlib<3.8
30+
matplotlib
3131
napari
3232
numpy
3333
tinycss2
34-
python_requires = >=3.8
34+
python_requires = >=3.9
3535
include_package_data = True
3636
package_dir =
3737
=src
@@ -49,6 +49,7 @@ napari.manifest =
4949
docs =
5050
napari[all]==0.4.17
5151
numpydoc
52+
pydantic<2
5253
pydata-sphinx-theme
5354
qtgallery
5455
sphinx

src/napari_matplotlib/base.py

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
import os
22
from pathlib import Path
3-
from typing import List, Optional, Tuple
3+
from typing import Optional
44

55
import matplotlib
66
import matplotlib.style as mplstyle
77
import napari
8-
from matplotlib.backends.backend_qtagg import (
9-
FigureCanvas,
8+
from matplotlib.backends.backend_qtagg import ( # type: ignore[attr-defined]
9+
FigureCanvasQTAgg,
1010
NavigationToolbar2QT,
1111
)
1212
from matplotlib.figure import Figure
@@ -49,12 +49,10 @@ def __init__(
4949

5050
# Sets figure.* style
5151
with mplstyle.context(self.mpl_style_sheet_path):
52-
self.canvas = FigureCanvas()
52+
self.canvas = FigureCanvasQTAgg() # type: ignore[no-untyped-call]
5353

5454
self.canvas.figure.set_layout_engine("constrained")
55-
self.toolbar = NapariNavigationToolbar(
56-
self.canvas, parent=self
57-
) # type: ignore[no-untyped-call]
55+
self.toolbar = NapariNavigationToolbar(self.canvas, parent=self)
5856
self._replace_toolbar_icons()
5957
# callback to update when napari theme changed
6058
# TODO: this isn't working completely (see issue #140)
@@ -97,7 +95,7 @@ def add_single_axes(self) -> None:
9795
# Sets axes.* style.
9896
# Does not set any text styling set by axes.* keys
9997
with mplstyle.context(self.mpl_style_sheet_path):
100-
self.axes = self.figure.subplots()
98+
self.axes = self.figure.add_subplot()
10199

102100
def _on_napari_theme_changed(self) -> None:
103101
"""
@@ -184,7 +182,7 @@ class NapariMPLWidget(BaseNapariMPLWidget):
184182
#: Number of layers taken as input
185183
n_layers_input = Interval(None, None)
186184
#: Type of layer taken as input
187-
input_layer_types: Tuple[napari.layers.Layer, ...] = (napari.layers.Layer,)
185+
input_layer_types: tuple[napari.layers.Layer, ...] = (napari.layers.Layer,)
188186

189187
def __init__(
190188
self,
@@ -193,7 +191,7 @@ def __init__(
193191
):
194192
super().__init__(napari_viewer=napari_viewer, parent=parent)
195193
self._setup_callbacks()
196-
self.layers: List[napari.layers.Layer] = []
194+
self.layers: list[napari.layers.Layer] = []
197195

198196
helper_text = self.n_layers_input._helper_text
199197
if helper_text is not None:
@@ -260,7 +258,7 @@ def _draw(self) -> None:
260258
isinstance(layer, self.input_layer_types) for layer in self.layers
261259
):
262260
self.draw()
263-
self.canvas.draw()
261+
self.canvas.draw() # type: ignore[no-untyped-call]
264262

265263
def clear(self) -> None:
266264
"""
@@ -309,8 +307,8 @@ def clear(self) -> None:
309307
class NapariNavigationToolbar(NavigationToolbar2QT):
310308
"""Custom Toolbar style for Napari."""
311309

312-
def __init__(self, *args, **kwargs): # type: ignore[no-untyped-def]
313-
super().__init__(*args, **kwargs)
310+
def __init__(self, *args, **kwargs) -> None: # type: ignore[no-untyped-def]
311+
super().__init__(*args, **kwargs) # type: ignore[no-untyped-call]
314312
self.setIconSize(
315313
from_napari_css_get_size_of(
316314
"QtViewerPushButton", fallback=(28, 28)
@@ -319,7 +317,7 @@ def __init__(self, *args, **kwargs): # type: ignore[no-untyped-def]
319317

320318
def _update_buttons_checked(self) -> None:
321319
"""Update toggle tool icons when selected/unselected."""
322-
super()._update_buttons_checked()
320+
super()._update_buttons_checked() # type: ignore[no-untyped-call]
323321
icon_dir = self.parentWidget()._get_path_to_icon()
324322

325323
# changes pan/zoom icons depending on state (checked or not)

src/napari_matplotlib/histogram.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, List, Optional, Tuple
1+
from typing import Any, Optional
22

33
import napari
44
import numpy as np
@@ -107,7 +107,7 @@ def _set_axis_keys(self, x_axis_key: str) -> None:
107107
self._x_axis_key = x_axis_key
108108
self._draw()
109109

110-
def _get_valid_axis_keys(self) -> List[str]:
110+
def _get_valid_axis_keys(self) -> list[str]:
111111
"""
112112
Get the valid axis keys from the layer FeatureTable.
113113
@@ -122,7 +122,7 @@ def _get_valid_axis_keys(self) -> List[str]:
122122
else:
123123
return self.layers[0].features.keys()
124124

125-
def _get_data(self) -> Tuple[Optional[npt.NDArray[Any]], str]:
125+
def _get_data(self) -> tuple[Optional[npt.NDArray[Any]], str]:
126126
"""Get the plot data.
127127
128128
Returns

src/napari_matplotlib/scatter.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, List, Optional, Tuple, Union
1+
from typing import Any, Optional, Union
22

33
import napari
44
import numpy.typing as npt
@@ -40,7 +40,7 @@ def draw(self) -> None:
4040
self.axes.set_xlabel(x_axis_name)
4141
self.axes.set_ylabel(y_axis_name)
4242

43-
def _get_data(self) -> Tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]:
43+
def _get_data(self) -> tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]:
4444
"""
4545
Get the plot data.
4646
@@ -67,7 +67,7 @@ class ScatterWidget(ScatterBaseWidget):
6767
n_layers_input = Interval(2, 2)
6868
input_layer_types = (napari.layers.Image,)
6969

70-
def _get_data(self) -> Tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]:
70+
def _get_data(self) -> tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]:
7171
"""
7272
Get the plot data.
7373
@@ -106,7 +106,7 @@ def __init__(
106106

107107
self.layout().addLayout(QVBoxLayout())
108108

109-
self._selectors: Dict[str, QComboBox] = {}
109+
self._selectors: dict[str, QComboBox] = {}
110110
for dim in ["x", "y"]:
111111
self._selectors[dim] = QComboBox()
112112
# Re-draw when combo boxes are updated
@@ -147,7 +147,7 @@ def y_axis_key(self, key: str) -> None:
147147
self._selectors["y"].setCurrentText(key)
148148
self._draw()
149149

150-
def _get_valid_axis_keys(self) -> List[str]:
150+
def _get_valid_axis_keys(self) -> list[str]:
151151
"""
152152
Get the valid axis keys from the layer FeatureTable.
153153
@@ -186,7 +186,7 @@ def draw(self) -> None:
186186
if self._ready_to_scatter():
187187
super().draw()
188188

189-
def _get_data(self) -> Tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]:
189+
def _get_data(self) -> tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]:
190190
"""
191191
Get the plot data from the ``features`` attribute of the first
192192
selected layer.

src/napari_matplotlib/slice.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, List, Optional, Tuple
1+
from typing import Any, Optional
22

33
import matplotlib.ticker as mticker
44
import napari
@@ -99,7 +99,7 @@ def current_dim_index(self) -> int:
9999
return self._dim_names.index(self.current_dim_name)
100100

101101
@property
102-
def _dim_names(self) -> List[str]:
102+
def _dim_names(self) -> list[str]:
103103
"""
104104
List of dimension names. This is a property as it varies depending on the
105105
dimensionality of the currently selected data.
@@ -111,7 +111,7 @@ def _dim_names(self) -> List[str]:
111111
else:
112112
raise RuntimeError("Don't know how to handle ndim != 2 or 3")
113113

114-
def _get_xy(self) -> Tuple[npt.NDArray[Any], npt.NDArray[Any]]:
114+
def _get_xy(self) -> tuple[npt.NDArray[Any], npt.NDArray[Any]]:
115115
"""
116116
Get data for plotting.
117117
"""
Loading
Loading

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy