Skip to content

Generalise functionality for plotting from feature tables #167

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 12 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move get_valid_axis_keys
  • Loading branch information
dstansby committed Jun 15, 2023
commit 5702ed9da4d07bf0efdef13081cc41e4fc0773dc
17 changes: 17 additions & 0 deletions src/napari_matplotlib/features.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from typing import List

import napari.layers

from napari_matplotlib.base import NapariMPLWidget
Expand All @@ -19,3 +21,18 @@ class FeaturesMixin(NapariMPLWidget):
napari.layers.Tracks,
napari.layers.Vectors,
)

def _get_valid_axis_keys(self) -> List[str]:
"""
Get the valid axis keys from the layer FeatureTable.

Returns
-------
axis_keys : List[str]
The valid axis keys in the FeatureTable. If the table is empty
or there isn't a table, returns an empty list.
"""
if len(self.layers) == 0 or not (hasattr(self.layers[0], "features")):
return []
else:
return self.layers[0].features.keys()
17 changes: 1 addition & 16 deletions src/napari_matplotlib/scatter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Optional, Tuple, Union
from typing import Any, Dict, Optional, Tuple, Union

import napari
import numpy.typing as npt
Expand Down Expand Up @@ -141,21 +141,6 @@ def y_axis_key(self, key: str) -> None:
self._selectors["y"].setCurrentText(key)
self._draw()

def _get_valid_axis_keys(self) -> List[str]:
"""
Get the valid axis keys from the layer FeatureTable.

Returns
-------
axis_keys : List[str]
The valid axis keys in the FeatureTable. If the table is empty
or there isn't a table, returns an empty list.
"""
if len(self.layers) == 0 or not (hasattr(self.layers[0], "features")):
return []
else:
return self.layers[0].features.keys()

def _ready_to_scatter(self) -> bool:
"""
Return True if selected layer has a feature table we can scatter with,
Expand Down