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
@@ -91,7 +91,7 @@ def bins_start(self) -> float:
91
91
return self .findChild (QDoubleSpinBox , name = "bins start" ).value ()
92
92
93
93
@bins_start .setter
94
- def bins_start (self , start : int | float ) -> None :
94
+ def bins_start (self , start : Union [ int , float ] ) -> None :
95
95
"""Set the minimum bin edge"""
96
96
self .findChild (QDoubleSpinBox , name = "bins start" ).setValue (start )
97
97
@@ -101,7 +101,7 @@ def bins_stop(self) -> float:
101
101
return self .findChild (QDoubleSpinBox , name = "bins stop" ).value ()
102
102
103
103
@bins_stop .setter
104
- def bins_stop (self , stop : int | float ) -> None :
104
+ def bins_stop (self , stop : Union [ int , float ] ) -> None :
105
105
"""Set the maximum bin edge"""
106
106
self .findChild (QDoubleSpinBox , name = "bins stop" ).setValue (stop )
107
107
@@ -115,14 +115,14 @@ def bins_num(self, num: int) -> None:
115
115
"""Set the number of bins to use"""
116
116
self .findChild (QSpinBox , name = "bins num" ).setValue (num )
117
117
118
- def autoset_widget_bins (self , data : npt .ArrayLike ) -> None :
118
+ def autoset_widget_bins (self , data : npt .NDArray [ Any ] ) -> None :
119
119
"""Update widgets with bins determined from the image data"""
120
120
bins = np .linspace (np .min (data ), np .max (data ), 100 , dtype = data .dtype )
121
121
self .bins_start = bins [0 ]
122
122
self .bins_stop = bins [- 1 ]
123
123
self .bins_num = bins .size
124
124
125
- def _get_layer_data (self , layer ) -> np . ndarray :
125
+ def _get_layer_data (self , layer : napari . layers . Layer ) -> npt . NDArray [ Any ] :
126
126
"""Get the data associated with a given layer"""
127
127
if layer .data .ndim - layer .rgb == 3 :
128
128
# 3D data, can be single channel or RGB
0 commit comments