Skip to content

Commit cfd6862

Browse files
committed
Task 1. | Milestone 1.c. → Done
1 parent df575a6 commit cfd6862

3 files changed

Lines changed: 24 additions & 4 deletions

File tree

cdl/utils/tests.py

Whitespace-only changes.

sigima_/__init__.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@
88
part of the DataLab open-source platform.
99
"""
1010

11+
# TODO: Use `numpy.typing.NDArray` for more precise type annotations once NumPy >= 1.21
12+
# can be safely required (e.g. after raising the minimum required version of
13+
# scikit-image to >= 0.19).
14+
1115
# The following comments are used to track the migration process of the `sigima_`
1216
# package, in the context of the DataLab Core Architecture Redesign project funded by
1317
# the NLnet Foundation.
1418

1519
# ---- Actions that can be done progressively, before the package is fully migrated ----
1620
# ** Task 1. Core Architecture Redesign **
1721
# ** Milestone 1.c. Redesign the API for the new core library **
18-
# TODO: Handle the NumPy minimum requirement to v1.21 to use advanced type hints?
19-
# TODO: Should we keep `PREFIX` attribute in `BaseObj`? (it's clearly useful for
20-
# `cdl` package, but not used in `sigima_` package - however, it may be tricky
21-
# to define it elsewhere, no?)
2222
#
2323
# ** Task 2. Technical Validation and Testing **
2424
# TODO: Add `pytest` infrastructure. Step 1: within `cdl` package, move pure `sigima_`

sigima_/obj/base.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,14 @@ class BaseResult(abc.ABC):
182182
labels: result labels (one label per column of result array)
183183
"""
184184

185+
#: Class attribute that defines a string prefix used to uniquely identify instances
186+
#: of this class in metadata serialization. Each subclass should override this with
187+
#: a unique identifier (e.g., "_properties_" for properties, "_shapes_" for shapes).
188+
#: This prefix is prepended to the object title when creating metadata keys,
189+
#: enabling type identification during deserialization.
185190
PREFIX = "" # To be overriden in children classes
191+
192+
#: Class attribute that defines a tuple of attributes to be serialized in metadata.
186193
METADATA_ATTRS = () # To be overriden in children classes
187194

188195
def __init__(
@@ -628,12 +635,21 @@ class NoDefaultOption:
628635
class BaseObj(Generic[TypeROI], metaclass=BaseObjMeta):
629636
"""Object (signal/image) interface"""
630637

638+
#: Class attribute that defines a string prefix used to uniquely identify instances
639+
#: of this class in metadata serialization. Each subclass should override this with
640+
#: a unique identifier (e.g., "s" for signals, "i" for images).
641+
#: This prefix is used as part of the key for storing and retrieving object-specific
642+
#: metadata, supporting type-based serialization and deserialization.
631643
PREFIX = "" # This is overriden in children classes
632644

633645
# This is overriden in children classes with a gds.DictItem instance:
634646
metadata: dict[str, Any] = {}
635647
annotations: str = ""
636648

649+
#: Class attribute that defines a tuple of valid NumPy data types supported by this
650+
#: class. This is used to validate the data type of the object when it is set or
651+
#: modified and to ensure that the object can handle the data correctly.
652+
#: Subclasses should override this with a specific set of valid data types.
637653
VALID_DTYPES = (np.float64,) # To be overriden in children classes
638654

639655
def __init__(self):
@@ -1228,6 +1244,10 @@ class BaseROI(Generic[TypeObj, TypeSingleROI, TypeROIParam], abc.ABC): # type:
12281244
inverse: if True, ROI is outside the region of interest
12291245
"""
12301246

1247+
#: Class attribute that defines a string prefix used for identifying ROI types
1248+
#: in object metadata. This prefix is used when serializing and deserializing ROIs,
1249+
#: allowing the system to determine the appropriate ROI class for reconstruction.
1250+
#: Each ROI subclass should override this with a unique string identifier.
12311251
PREFIX = "" # This is overriden in children classes
12321252

12331253
def __init__(self, singleobj: bool | None = None, inverse: bool = False) -> None:

0 commit comments

Comments
 (0)