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
@@ -107,16 +117,13 @@ def bins_num(self, num: int) -> None:
107
117
108
118
def autoset_widget_bins (self , data : npt .ArrayLike ) -> None :
109
119
"""Update widgets with bins determined from the image data"""
110
-
111
120
bins = np .linspace (np .min (data ), np .max (data ), 100 , dtype = data .dtype )
112
121
self .bins_start = bins [0 ]
113
122
self .bins_stop = bins [- 1 ]
114
123
self .bins_num = bins .size
115
124
116
-
117
125
def _get_layer_data (self , layer ) -> np .ndarray :
118
126
"""Get the data associated with a given layer"""
119
-
120
127
if layer .data .ndim - layer .rgb == 3 :
121
128
# 3D data, can be single channel or RGB
122
129
data = layer .data [self .current_z ]
@@ -133,7 +140,6 @@ def on_update_layers(self) -> None:
133
140
"""
134
141
Called when the layer selection changes by ``self._update_layers()``.
135
142
"""
136
-
137
143
if not self .layers :
138
144
return
139
145
@@ -143,8 +149,12 @@ def on_update_layers(self) -> None:
143
149
144
150
# Only allow integer bins for integer data
145
151
n_decimals = 0 if np .issubdtype (layer_data .dtype , np .integer ) else 2
146
- self .findChild (QDoubleSpinBox , name = "bins start" ).setDecimals (n_decimals )
147
- self .findChild (QDoubleSpinBox , name = "bins stop" ).setDecimals (n_decimals )
152
+ self .findChild (QDoubleSpinBox , name = "bins start" ).setDecimals (
153
+ n_decimals
154
+ )
155
+ self .findChild (QDoubleSpinBox , name = "bins stop" ).setDecimals (
156
+ n_decimals
157
+ )
148
158
149
159
def draw (self ) -> None :
150
160
"""
0 commit comments