1
- from typing import Any , Optional , cast
1
+ from typing import Any , Optional , Union , cast
2
2
3
3
import napari
4
4
import numpy as np
@@ -108,7 +108,7 @@ def bins_start(self) -> float:
108
108
return self .findChild (QDoubleSpinBox , name = "bins start" ).value ()
109
109
110
110
@bins_start .setter
111
- def bins_start (self , start : int | float ) -> None :
111
+ def bins_start (self , start : Union [ int , float ] ) -> None :
112
112
"""Set the minimum bin edge"""
113
113
self .findChild (QDoubleSpinBox , name = "bins start" ).setValue (start )
114
114
@@ -118,7 +118,7 @@ def bins_stop(self) -> float:
118
118
return self .findChild (QDoubleSpinBox , name = "bins stop" ).value ()
119
119
120
120
@bins_stop .setter
121
- def bins_stop (self , stop : int | float ) -> None :
121
+ def bins_stop (self , stop : Union [ int , float ] ) -> None :
122
122
"""Set the maximum bin edge"""
123
123
self .findChild (QDoubleSpinBox , name = "bins stop" ).setValue (stop )
124
124
@@ -132,14 +132,14 @@ def bins_num(self, num: int) -> None:
132
132
"""Set the number of bins to use"""
133
133
self .findChild (QSpinBox , name = "bins num" ).setValue (num )
134
134
135
- def autoset_widget_bins (self , data : npt .ArrayLike ) -> None :
135
+ def autoset_widget_bins (self , data : npt .NDArray [ Any ] ) -> None :
136
136
"""Update widgets with bins determined from the image data"""
137
137
bins = np .linspace (np .min (data ), np .max (data ), 100 , dtype = data .dtype )
138
138
self .bins_start = bins [0 ]
139
139
self .bins_stop = bins [- 1 ]
140
140
self .bins_num = bins .size
141
141
142
- def _get_layer_data (self , layer ) -> np . ndarray :
142
+ def _get_layer_data (self , layer : napari . layers . Layer ) -> npt . NDArray [ Any ] :
143
143
"""Get the data associated with a given layer"""
144
144
if layer .data .ndim - layer .rgb == 3 :
145
145
# 3D data, can be single channel or RGB
0 commit comments