From 92d62cd355c80f323c904939fc7cb6196487ccc0 Mon Sep 17 00:00:00 2001 From: Julia Dark Date: Tue, 30 Jul 2024 14:19:45 -0400 Subject: [PATCH] Add `add_new_level` to Image2D --- python-spec/src/somacore/ephemeral/collections.py | 13 +++++++++++++ python-spec/src/somacore/images.py | 14 +++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/python-spec/src/somacore/ephemeral/collections.py b/python-spec/src/somacore/ephemeral/collections.py index f6ce6598..d570ecb6 100644 --- a/python-spec/src/somacore/ephemeral/collections.py +++ b/python-spec/src/somacore/ephemeral/collections.py @@ -5,7 +5,9 @@ MutableMapping, NoReturn, Optional, + Sequence, TypeVar, + Union, ) import pyarrow as pa @@ -169,6 +171,17 @@ class Image2D( # type: ignore[misc] # __eq__ false positive __slots__ = () + def add_new_level( + self, + key: str, + *, + uri: Optional[str] = None, + type: pa.DataType, + shape: Sequence[int], + axes: Union[str, Sequence[str]], + ) -> data.DenseNDArray: + raise NotImplementedError() + @property def level_count(self) -> int: raise NotImplementedError() diff --git a/python-spec/src/somacore/images.py b/python-spec/src/somacore/images.py index 1ce7f62a..a25387cb 100644 --- a/python-spec/src/somacore/images.py +++ b/python-spec/src/somacore/images.py @@ -1,7 +1,7 @@ """Implementation of the SOMA image collection for spatial data""" import abc -from typing import Generic, Optional, Tuple, TypeVar +from typing import Generic, Optional, Sequence, Tuple, TypeVar, Union import pyarrow as pa from typing_extensions import Final, Protocol @@ -58,6 +58,18 @@ def name(self) -> str: def shape(self) -> Tuple[int, ...]: """Number of pixels for each dimension of the image.""" + @abc.abstractmethod + def add_new_level( + self, + key: str, + *, + uri: Optional[str] = None, + type: pa.DataType, + shape: Sequence[int], + axes: Union[str, Sequence[str]], + ) -> data.DenseNDArray: + raise NotImplementedError() + @property @abc.abstractmethod def level_count(self) -> int: