File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change 11from copy import deepcopy
22
3+ import numpy as np
34import pytest
45
56from napari_matplotlib import FeaturesHistogramWidget , HistogramWidget
@@ -35,8 +36,6 @@ def test_histogram_3D(make_napari_viewer, brain_data):
3536
3637
3738def 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
7473def 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
You can’t perform that action at this time.
0 commit comments