Skip to content

Commit 358c018

Browse files
authored
Merge branch 'main' into pre-commit-ci-update-config
2 parents ae412cb + 87763d3 commit 358c018

File tree

4 files changed

+17
-9
lines changed

4 files changed

+17
-9
lines changed

pyproject.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ build-backend = "setuptools.build_meta"
66
write_to = "src/napari_matplotlib/_version.py"
77

88
[tool.pytest.ini_options]
9-
qt_api = "pyqt6"
10-
addopts = "--mpl --mpl-baseline-relative"
119
filterwarnings = [
1210
"error",
11+
"ignore:(?s).*Pyarrow will become a required dependency of pandas",
1312
# Coming from vispy
1413
"ignore:distutils Version classes are deprecated:DeprecationWarning",
1514
"ignore:`np.bool8` is a deprecated alias for `np.bool_`:DeprecationWarning",
1615
]
16+
qt_api = "pyqt6"
17+
addopts = "--mpl --mpl-baseline-relative"
1718

1819
[tool.black]
1920
line-length = 79

src/napari_matplotlib/histogram.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
import numpy as np
55
import numpy.typing as npt
66
from matplotlib.container import BarContainer
7+
from napari.layers import Image
8+
from napari.layers._multiscale_data import MultiScaleData
79
from qtpy.QtWidgets import (
810
QComboBox,
911
QLabel,
@@ -26,8 +28,9 @@ def _get_bins(data: npt.NDArray[Any]) -> npt.NDArray[Any]:
2628
step = np.ceil(np.ptp(data) / 100)
2729
return np.arange(np.min(data), np.max(data) + step, step)
2830
else:
29-
# For other data types, just have 128 evenly spaced bins
30-
return np.linspace(np.min(data), np.max(data), 100)
31+
# For other data types, just have 100 evenly spaced bins
32+
# (and 101 bin edges)
33+
return np.linspace(np.min(data), np.max(data), 101)
3134

3235

3336
class HistogramWidget(SingleAxesWidget):
@@ -67,14 +70,18 @@ def draw(self) -> None:
6770
"""
6871
Clear the axes and histogram the currently selected layer/slice.
6972
"""
70-
layer = self.layers[0]
73+
layer: Image = self.layers[0]
74+
data = layer.data
7175

72-
if layer.data.ndim - layer.rgb == 3:
76+
if isinstance(layer.data, MultiScaleData):
77+
data = data[layer.data_level]
78+
79+
if layer.ndim - layer.rgb == 3:
7380
# 3D data, can be single channel or RGB
74-
data = layer.data[self.current_z]
81+
# Slice in z dimension
82+
data = data[self.current_z]
7583
self.axes.set_title(f"z={self.current_z}")
76-
else:
77-
data = layer.data
84+
7885
# Read data into memory if it's a dask array
7986
data = np.asarray(data)
8087

Loading
Loading

0 commit comments

Comments
 (0)