Skip to content

Commit ef1029b

Browse files
committed
update docstrings
1 parent 5a58dd9 commit ef1029b

File tree

1 file changed

+56
-5
lines changed

1 file changed

+56
-5
lines changed

src/napari_matplotlib/scatter.py

Lines changed: 56 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,20 @@ def draw(self) -> None:
6565
self.axes.set_xlabel(x_axis_name)
6666
self.axes.set_ylabel(y_axis_name)
6767

68-
def _get_data(self) -> Tuple[np.ndarray, str, str]:
68+
def _get_data(self) -> Tuple[List[np.ndarray], str, str]:
69+
"""Get the plot data.
70+
71+
This must be implemented on the subclass.
72+
73+
Returns
74+
-------
75+
data : np.ndarray
76+
The list containing the scatter plot data.
77+
x_axis_name : str
78+
The title to display on the x axis
79+
y_axis_name: str
80+
The title to display on the y axis
81+
"""
6982
raise NotImplementedError
7083

7184

@@ -91,7 +104,18 @@ def __init__(
91104
histogram_for_large_data=histogram_for_large_data,
92105
)
93106

94-
def _get_data(self) -> Tuple[np.ndarray, str, str]:
107+
def _get_data(self) -> Tuple[List[np.ndarray], str, str]:
108+
"""Get the plot data.
109+
110+
Returns
111+
-------
112+
data : List[np.ndarray]
113+
List contains the in view slice of X and Y axis images.
114+
x_axis_name : str
115+
The title to display on the x axis
116+
y_axis_name: str
117+
The title to display on the y axis
118+
"""
95119
data = [layer.data[self.current_z] for layer in self.layers]
96120
x_axis_name = self.layers[0].name
97121
y_axis_name = self.layers[1].name
@@ -152,12 +176,39 @@ def _set_axis_keys(self, x_axis_key: str, y_axis_key: str):
152176
self._draw()
153177

154178
def _get_valid_axis_keys(self, combo_widget=None) -> List[str]:
155-
if len(self.layers) == 0:
179+
"""Get the valid axis keys from the layer FeatureTable.
180+
181+
Returns
182+
-------
183+
axis_keys : List[str]
184+
The valid axis keys in the FeatureTable. If the table is empty
185+
or there isn't a table, returns an empty list.
186+
"""
187+
if len(self.layers) == 0 or not (hasattr(self.layers[0], "features")):
156188
return []
157189
else:
158190
return self.layers[0].features.keys()
159191

160-
def _get_data(self) -> Tuple[np.ndarray, str, str]:
192+
def _get_data(self) -> Tuple[List[np.ndarray], str, str]:
193+
"""Get the plot data.
194+
195+
Returns
196+
-------
197+
data : List[np.ndarray]
198+
List contains X and Y columns from the FeatureTable. Returns
199+
an empty array if nothing to plot.
200+
x_axis_name : str
201+
The title to display on the x axis. Returns
202+
an empty string if nothing to plot.
203+
y_axis_name: str
204+
The title to display on the y axis. Returns
205+
an empty string if nothing to plot.
206+
"""
207+
if not hasattr(self.layers[0], "features"):
208+
# if the selected layer doesn't have a featuretable,
209+
# skip draw
210+
return np.array([]), "", ""
211+
161212
feature_table = self.layers[0].features
162213

163214
if (
@@ -169,7 +220,7 @@ def _get_data(self) -> Tuple[np.ndarray, str, str]:
169220

170221
data_x = feature_table[self.x_axis_key]
171222
data_y = feature_table[self.y_axis_key]
172-
data = np.stack((data_x, data_y))
223+
data = [data_x, data_y]
173224

174225
x_axis_name = self.x_axis_key.replace("_", " ")
175226
y_axis_name = self.y_axis_key.replace("_", " ")

0 commit comments

Comments
 (0)