From 5348d6064975dc93b1f063f80462258fd65b03be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Weber?= Date: Fri, 7 Mar 2025 09:45:49 +0100 Subject: [PATCH] register with decorator --- src/pymodaq_data/data.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/pymodaq_data/data.py b/src/pymodaq_data/data.py index dbba18d3..b74741cc 100644 --- a/src/pymodaq_data/data.py +++ b/src/pymodaq_data/data.py @@ -182,6 +182,7 @@ def _compute_slices_from_axis(axis: Axis, _slice, *ignored, is_index=True, **ign return _slice +@ser_factory.register_decorator() class Axis(SerializableBase): """Object holding info and data about physical axis of some data @@ -619,6 +620,7 @@ def find_indexes(self, thresholds: IterableType[float]) -> IterableType[int]: return [self.find_index(threshold) for threshold in thresholds] +@ser_factory.register_decorator() class NavAxis(Axis): def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) @@ -1846,6 +1848,7 @@ def _get_dimension_str(self): return string +@ser_factory.register_decorator() class DataWithAxes(DataBase, SerializableBase): """Data object with Axis objects corresponding to underlying data nd-arrays @@ -1867,7 +1870,7 @@ class DataWithAxes(DataBase, SerializableBase): def __new__(cls, *args, **kwargs): ser_factory.register_from_type(cls, cls.serialize, cls.deserialize) # implement - # serialization/deserialization to all subtypes of DataBase + # serialization/deserialization to all subtypes of DataBase but only when first instantiated hence the decorator return super().__new__(cls) def __init__(self, name: str, @@ -2781,6 +2784,7 @@ def get_data_as_dwa(self, index: int = 0) -> DataWithAxes: return self.deepcopy_with_new_data([self[index]]) +@ser_factory.register_decorator() class DataRaw(DataWithAxes): """Specialized DataWithAxes set with source as 'raw'. To be used for raw data""" def __init__(self, name: str, @@ -2810,6 +2814,7 @@ def __init__(self, name: str, ) +@ser_factory.register_decorator() class DataCalculated(DataWithAxes): """Specialized DataWithAxes set with source as 'calculated'. To be used for processed/calculated data""" @@ -2839,6 +2844,7 @@ def __init__(self, name: str, **kwargs) +@ser_factory.register_decorator() class DataFromRoi(DataCalculated): """Specialized DataWithAxes set with source as 'calculated'. To be used for processed data from region of interest""" @@ -2866,6 +2872,7 @@ def __init__(self, name: str, **kwargs) +@ser_factory.register_decorator() class DataToExport(DataLowLevel, SerializableBase): """Object to store all raw and calculated DataWithAxes data for later exporting, saving, sending signal...