Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fb1e6df

Browse files
committed
scatter working with print statements
1 parent 0d7e1be commit fb1e6df

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/napari_matplotlib/scatter.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,19 +24,22 @@ def __init__(
2424
napari_viewer: napari.viewer.Viewer,
2525
parent: Optional[QWidget] = None,
2626
):
27+
print("ScatterBase init")
2728
super().__init__(napari_viewer, parent=parent)
2829
self.add_single_axes()
2930

3031
def clear(self) -> None:
3132
"""
3233
Clear the axes.
3334
"""
35+
print("ScatterBase clear")
3436
self.axes.clear()
3537

3638
def draw(self) -> None:
3739
"""
3840
Scatter the currently selected layers.
3941
"""
42+
print("ScatterBase draw")
4043
x, y, x_axis_name, y_axis_name = self._get_data()
4144

4245
if x.size > self._threshold_to_switch_to_histogram:
@@ -91,6 +94,7 @@ def _get_data(self) -> Tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]:
9194
y_axis_name: str
9295
The title to display on the y axis
9396
"""
97+
print("Scatter get data")
9498
x = self.layers[0].data[self.current_z]
9599
y = self.layers[1].data[self.current_z]
96100
x_axis_name = self.layers[0].name
@@ -119,12 +123,14 @@ def __init__(
119123
napari_viewer: napari.viewer.Viewer,
120124
parent: Optional[QWidget] = None,
121125
):
126+
print("FeatureScatter init")
122127
super().__init__(napari_viewer, parent=parent)
123128

124129
self.layout().addLayout(QVBoxLayout())
125130

126131
self._selectors: Dict[str, QComboBox] = {}
127132
for dim in ["x", "y"]:
133+
# pdb.set_trace()
128134
self._selectors[dim] = QComboBox()
129135
# Re-draw when combo boxes are updated
130136
self._selectors[dim].currentTextChanged.connect(self._draw)
@@ -139,13 +145,17 @@ def x_axis_key(self) -> Union[str, None]:
139145
"""
140146
Key for the x-axis data.
141147
"""
148+
# print('Feat x axis key @property')
142149
if self._selectors["x"].count() == 0:
150+
print("IF X self selectors count = 0")
143151
return None
144152
else:
153+
# print('ELSE X self selectors currentText')
145154
return self._selectors["x"].currentText()
146155

147156
@x_axis_key.setter
148157
def x_axis_key(self, key: str) -> None:
158+
print("Feat x axis key @setter = ", key)
149159
self._selectors["x"].setCurrentText(key)
150160
self._draw()
151161

@@ -154,13 +164,17 @@ def y_axis_key(self) -> Union[str, None]:
154164
"""
155165
Key for the y-axis data.
156166
"""
167+
# print('Feat y axis key @property')
157168
if self._selectors["y"].count() == 0:
169+
print("IF Y self selectors count = 0")
158170
return None
159171
else:
172+
# print('ELSE Y self selectors currentText')
160173
return self._selectors["y"].currentText()
161174

162175
@y_axis_key.setter
163176
def y_axis_key(self, key: str) -> None:
177+
print("Feat y axis key @setter = ", key)
164178
self._selectors["y"].setCurrentText(key)
165179
self._draw()
166180

@@ -174,6 +188,7 @@ def _get_valid_axis_keys(self) -> List[str]:
174188
The valid axis keys in the FeatureTable. If the table is empty
175189
or there isn't a table, returns an empty list.
176190
"""
191+
print("Feat get valid axis keys")
177192
if len(self.layers) == 0 or not (hasattr(self.layers[0], "features")):
178193
return []
179194
else:
@@ -184,6 +199,8 @@ def _ready_to_scatter(self) -> bool:
184199
Return True if selected layer has a feature table we can scatter with,
185200
and the two columns to be scatterd have been selected.
186201
"""
202+
# pdb.set_trace()
203+
print("Feat ready to scatter")
187204
if not hasattr(self.layers[0], "features"):
188205
return False
189206

@@ -200,6 +217,7 @@ def draw(self) -> None:
200217
"""
201218
Scatter two features from the currently selected layer.
202219
"""
220+
print("Feat draw")
203221
if self._ready_to_scatter():
204222
super().draw()
205223

@@ -221,6 +239,7 @@ def _get_data(self) -> Tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]:
221239
an empty string if nothing to plot.
222240
"""
223241
# pdb.set_trace()
242+
print("Feat get data")
224243
feature_table = self.layers[0].features
225244

226245
x = feature_table[self.x_axis_key]
@@ -229,15 +248,20 @@ def _get_data(self) -> Tuple[npt.NDArray[Any], npt.NDArray[Any], str, str]:
229248
x_axis_name = str(self.x_axis_key)
230249
y_axis_name = str(self.y_axis_key)
231250

251+
print("x-axis = ", str(self.x_axis_key))
252+
print("y-axis = ", str(self.y_axis_key))
253+
232254
return x, y, x_axis_name, y_axis_name
233255

234256
def on_update_layers(self) -> None:
235257
"""
236258
Called when the layer selection changes by ``self.update_layers()``.
237259
"""
238260
# Clear combobox
261+
print("Feat on update layers")
239262
for dim in ["x", "y"]:
240263
while self._selectors[dim].count() > 0:
241264
self._selectors[dim].removeItem(0)
242265
# Add keys for newly selected layer
266+
# pdb.set_trace()
243267
self._selectors[dim].addItems(self._get_valid_axis_keys())

0 commit comments

Comments
 (0)