Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 80ec91f

Browse filesBrowse files
committed
Run pre-commit and fix typing
1 parent 5e9604b commit 80ec91f
Copy full SHA for 80ec91f

File tree

2 files changed

+7
-7
lines changed
Filter options

2 files changed

+7
-7
lines changed

‎src/napari_matplotlib/histogram.py

Copy file name to clipboardExpand all lines: src/napari_matplotlib/histogram.py
+4-4Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -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[npt.NDArray[Any], str]:
125+
def _get_data(self) -> Tuple[Optional[npt.NDArray[Any]], str]:
126126
"""Get the plot data.
127127
128128
Returns
@@ -137,12 +137,12 @@ def _get_data(self) -> Tuple[npt.NDArray[Any], str]:
137137
if not hasattr(self.layers[0], "features"):
138138
# if the selected layer doesn't have a featuretable,
139139
# skip draw
140-
return [], ""
140+
return None, ""
141141

142142
feature_table = self.layers[0].features
143143

144144
if (len(feature_table) == 0) or (self.x_axis_key is None):
145-
return [], ""
145+
return None, ""
146146

147147
data = feature_table[self.x_axis_key]
148148
x_axis_name = self.x_axis_key.replace("_", " ")
@@ -164,7 +164,7 @@ def draw(self) -> None:
164164
"""Clear the axes and histogram the currently selected layer/slice."""
165165
data, x_axis_name = self._get_data()
166166

167-
if len(data) == 0:
167+
if data is None:
168168
return
169169

170170
self.axes.hist(data, bins=50, edgecolor="white", linewidth=0.3)

‎src/napari_matplotlib/tests/test_histogram.py

Copy file name to clipboardExpand all lines: src/napari_matplotlib/tests/test_histogram.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from copy import deepcopy
22

3+
import numpy as np
34
import pytest
45

56
from napari_matplotlib import FeaturesHistogramWidget, HistogramWidget
@@ -35,8 +36,6 @@ def test_histogram_3D(make_napari_viewer, brain_data):
3536

3637

3738
def test_feature_histogram(make_napari_viewer):
38-
import numpy as np
39-
4039
n_points = 1000
4140
random_points = np.random.random((n_points, 3)) * 10
4241
feature1 = np.random.random(n_points)
@@ -72,7 +71,8 @@ def test_feature_histogram(make_napari_viewer):
7271

7372
@pytest.mark.mpl_image_compare
7473
def test_feature_histogram2(make_napari_viewer):
75-
import numpy as np
74+
import numpy as np
75+
7676
np.random.seed(0)
7777
n_points = 1000
7878
random_points = np.random.random((n_points, 3)) * 10

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.