Skip to content
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

add graph layer #292

Merged
merged 15 commits into from
Jul 6, 2023
2 changes: 1 addition & 1 deletion _docs/templates/_npe2_writers_guide.md.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ by the corresponding writer contribution in the manifest).
```python
DataType = Any # usually something like a numpy array, but varies by layer
LayerAttributes = dict
LayerName = Literal["image", "labels", "points", "shapes", "surface", "tracks", "vectors"]
LayerName = Literal["graph", "image", "labels", "points", "shapes", "surface", "tracks", "vectors"]
FullLayerData = Tuple[DataType, LayerAttributes, LayerName]
MultiWriterFunction = Callable[[str, List[FullLayerData]], List[str]]
```
Expand Down
3 changes: 3 additions & 0 deletions src/npe2/_inspection/_visitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ def napari_get_writer(self, node: ast.FunctionDef):
# we can't convert this to an npe2 command contribution
pass # pragma: no cover

def napari_write_graph(self, node: ast.FunctionDef):
self._parse_writer(node, "graph") # pragma: no cover

def napari_write_image(self, node: ast.FunctionDef):
self._parse_writer(node, "image")

Expand Down
1 change: 1 addition & 0 deletions src/npe2/manifest/contributions/_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@


class LayerType(str, Enum):
graph = "graph"
image = "image"
labels = "labels"
points = "points"
Expand Down
2 changes: 1 addition & 1 deletion src/npe2/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def __array__(self) -> "np.ndarray":


LayerName = Literal[
"image", "labels", "points", "shapes", "surface", "tracks", "vectors"
"graph", "image", "labels", "points", "shapes", "surface", "tracks", "vectors"
]
Metadata = Dict
DataType = Union[ArrayLike, Sequence[ArrayLike]]
Expand Down
1 change: 1 addition & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ class HookSpecs:
def napari_provide_sample_data(): ... # type: ignore
def napari_get_reader(path): ...
def napari_get_writer(path, layer_types): ...
def napari_write_graph(path, data, meta): ...
def napari_write_image(path, data, meta): ...
def napari_write_labels(path, data, meta): ...
def napari_write_points(path, data, meta): ...
Expand Down