Skip to content

Commit 68275f4

Browse files
committed
Move get_valid_axis_keys
1 parent 17ec286 commit 68275f4

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

Diff for: src/napari_matplotlib/features.py

+17
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
from typing import List
2+
13
import napari.layers
24

35
from napari_matplotlib.base import NapariMPLWidget
@@ -19,3 +21,18 @@ class FeaturesMixin(NapariMPLWidget):
1921
napari.layers.Tracks,
2022
napari.layers.Vectors,
2123
)
24+
25+
def _get_valid_axis_keys(self) -> List[str]:
26+
"""
27+
Get the valid axis keys from the layer FeatureTable.
28+
29+
Returns
30+
-------
31+
axis_keys : List[str]
32+
The valid axis keys in the FeatureTable. If the table is empty
33+
or there isn't a table, returns an empty list.
34+
"""
35+
if len(self.layers) == 0 or not (hasattr(self.layers[0], "features")):
36+
return []
37+
else:
38+
return self.layers[0].features.keys()

Diff for: src/napari_matplotlib/scatter.py

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, Dict, List, Optional, Tuple, Union
1+
from typing import Any, Dict, Optional, Tuple, Union
22

33
import napari
44
import numpy.typing as npt
@@ -141,21 +141,6 @@ def y_axis_key(self, key: str) -> None:
141141
self._selectors["y"].setCurrentText(key)
142142
self._draw()
143143

144-
def _get_valid_axis_keys(self) -> List[str]:
145-
"""
146-
Get the valid axis keys from the layer FeatureTable.
147-
148-
Returns
149-
-------
150-
axis_keys : List[str]
151-
The valid axis keys in the FeatureTable. If the table is empty
152-
or there isn't a table, returns an empty list.
153-
"""
154-
if len(self.layers) == 0 or not (hasattr(self.layers[0], "features")):
155-
return []
156-
else:
157-
return self.layers[0].features.keys()
158-
159144
def _ready_to_scatter(self) -> bool:
160145
"""
161146
Return True if selected layer has a feature table we can scatter with,

0 commit comments

Comments
 (0)