1- from typing import Any ,Optional ,cast
1+ from typing import Any ,Optional ,Union , cast
22
33import napari
44import numpy as np
@@ -91,7 +91,7 @@ def bins_start(self) -> float:
9191return self .findChild (QDoubleSpinBox ,name = "bins start" ).value ()
9292
9393@bins_start .setter
94- def bins_start (self ,start :int | float )-> None :
94+ def bins_start (self ,start :Union [ int , float ] )-> None :
9595"""Set the minimum bin edge"""
9696self .findChild (QDoubleSpinBox ,name = "bins start" ).setValue (start )
9797
@@ -101,7 +101,7 @@ def bins_stop(self) -> float:
101101return self .findChild (QDoubleSpinBox ,name = "bins stop" ).value ()
102102
103103@bins_stop .setter
104- def bins_stop (self ,stop :int | float )-> None :
104+ def bins_stop (self ,stop :Union [ int , float ] )-> None :
105105"""Set the maximum bin edge"""
106106self .findChild (QDoubleSpinBox ,name = "bins stop" ).setValue (stop )
107107
@@ -115,14 +115,14 @@ def bins_num(self, num: int) -> None:
115115"""Set the number of bins to use"""
116116self .findChild (QSpinBox ,name = "bins num" ).setValue (num )
117117
118- def autoset_widget_bins (self ,data :npt .ArrayLike )-> None :
118+ def autoset_widget_bins (self ,data :npt .NDArray [ Any ] )-> None :
119119"""Update widgets with bins determined from the image data"""
120120bins = np .linspace (np .min (data ),np .max (data ),100 ,dtype = data .dtype )
121121self .bins_start = bins [0 ]
122122self .bins_stop = bins [- 1 ]
123123self .bins_num = bins .size
124124
125- def _get_layer_data (self ,layer )-> np . ndarray :
125+ def _get_layer_data (self ,layer : napari . layers . Layer )-> npt . NDArray [ Any ] :
126126"""Get the data associated with a given layer"""
127127if layer .data .ndim - layer .rgb == 3 :
128128# 3D data, can be single channel or RGB