4
4
import numpy as np
5
5
import numpy .typing as npt
6
6
from matplotlib .container import BarContainer
7
- from qtpy .QtWidgets import QComboBox , QLabel , QVBoxLayout , QWidget , QGroupBox , QFormLayout , QDoubleSpinBox , QSpinBox , QAbstractSpinBox
7
+ from qtpy .QtWidgets import (
8
+ QAbstractSpinBox ,
9
+ QComboBox ,
10
+ QDoubleSpinBox ,
11
+ QFormLayout ,
12
+ QGroupBox ,
13
+ QLabel ,
14
+ QSpinBox ,
15
+ QVBoxLayout ,
16
+ QWidget ,
17
+ )
8
18
9
19
from .base import SingleAxesWidget
10
20
from .features import FEATURES_LAYER_TYPES
@@ -124,16 +134,13 @@ def bins_num(self, num: int) -> None:
124
134
125
135
def autoset_widget_bins (self , data : npt .ArrayLike ) -> None :
126
136
"""Update widgets with bins determined from the image data"""
127
-
128
137
bins = np .linspace (np .min (data ), np .max (data ), 100 , dtype = data .dtype )
129
138
self .bins_start = bins [0 ]
130
139
self .bins_stop = bins [- 1 ]
131
140
self .bins_num = bins .size
132
141
133
-
134
142
def _get_layer_data (self , layer ) -> np .ndarray :
135
143
"""Get the data associated with a given layer"""
136
-
137
144
if layer .data .ndim - layer .rgb == 3 :
138
145
# 3D data, can be single channel or RGB
139
146
data = layer .data [self .current_z ]
@@ -150,7 +157,6 @@ def on_update_layers(self) -> None:
150
157
"""
151
158
Called when the layer selection changes by ``self._update_layers()``.
152
159
"""
153
-
154
160
if not self .layers :
155
161
return
156
162
@@ -160,8 +166,12 @@ def on_update_layers(self) -> None:
160
166
161
167
# Only allow integer bins for integer data
162
168
n_decimals = 0 if np .issubdtype (layer_data .dtype , np .integer ) else 2
163
- self .findChild (QDoubleSpinBox , name = "bins start" ).setDecimals (n_decimals )
164
- self .findChild (QDoubleSpinBox , name = "bins stop" ).setDecimals (n_decimals )
169
+ self .findChild (QDoubleSpinBox , name = "bins start" ).setDecimals (
170
+ n_decimals
171
+ )
172
+ self .findChild (QDoubleSpinBox , name = "bins stop" ).setDecimals (
173
+ n_decimals
174
+ )
165
175
166
176
def draw (self ) -> None :
167
177
"""
0 commit comments