diff options
author | Théo de la Hogue | 2024-04-26 03:54:14 +0200 |
---|---|---|
committer | Théo de la Hogue | 2024-04-26 03:54:14 +0200 |
commit | 6125539d82e13edc8a8df56a4e08483b9b4e43a4 (patch) | |
tree | b0a134ff24ab6dc2a0a44aa5b2ac93c655cc2bbf /src/argaze/GazeFeatures.py | |
parent | 6e150b914e3bb0a7718410363498efb794b4ecbc (diff) | |
download | argaze-6125539d82e13edc8a8df56a4e08483b9b4e43a4.zip argaze-6125539d82e13edc8a8df56a4e08483b9b4e43a4.tar.gz argaze-6125539d82e13edc8a8df56a4e08483b9b4e43a4.tar.bz2 argaze-6125539d82e13edc8a8df56a4e08483b9b4e43a4.tar.xz |
Replacing TimestampedObject class by a @timestamp decorator.
Diffstat (limited to 'src/argaze/GazeFeatures.py')
-rw-r--r-- | src/argaze/GazeFeatures.py | 41 |
1 files changed, 11 insertions, 30 deletions
diff --git a/src/argaze/GazeFeatures.py b/src/argaze/GazeFeatures.py index 32b7de7..5ef3c32 100644 --- a/src/argaze/GazeFeatures.py +++ b/src/argaze/GazeFeatures.py @@ -28,8 +28,8 @@ import pandas from argaze import DataFeatures from argaze.AreaOfInterest import AOIFeatures - -class GazePosition(tuple, DataFeatures.TimestampedObject): +@DataFeatures.timestamp +class GazePosition(tuple): """Define gaze position as a tuple of coordinates with precision. Parameters: @@ -37,15 +37,12 @@ class GazePosition(tuple, DataFeatures.TimestampedObject): message: a string to describe why the position is what it is. """ - def __new__(cls, position: tuple = (), precision: int | float = None, message: str = None, - timestamp: int | float = math.nan): + def __new__(cls, position: tuple = (), **kwargs): return tuple.__new__(cls, position) - def __init__(self, position: tuple = (), precision: int | float = None, message: str = None, - timestamp: int | float = math.nan): + def __init__(self, position: tuple = (), precision: int | float = None, message: str = None): - DataFeatures.TimestampedObject.__init__(self, timestamp) self.__precision = precision self.__message = message @@ -392,8 +389,8 @@ class GazePositionCalibrator(DataFeatures.PipelineStepObject): raise NotImplementedError('ready getter not implemented') - -class GazeMovement(TimeStampedGazePositions, DataFeatures.TimestampedObject): +@DataFeatures.timestamp +class GazeMovement(TimeStampedGazePositions): """Define abstract gaze movement class as timestamped gaze positions list. !!! note @@ -410,30 +407,14 @@ class GazeMovement(TimeStampedGazePositions, DataFeatures.TimestampedObject): # noinspection PyArgumentList return TimeStampedGazePositions.__new__(cls, positions) - def __init__(self, positions: TimeStampedGazePositions = None, finished: bool = False, message: str = None, timestamp: int | float = math.nan): + def __init__(self, positions: TimeStampedGazePositions = None, finished: bool = False, message: str = None): """Initialize GazeMovement""" TimeStampedGazePositions.__init__(self, positions) - DataFeatures.TimestampedObject.__init__(self, timestamp) self.__finished = finished self.__message = message - @property - def timestamp(self) -> int | float: - """Get first position timestamp.""" - if self: - return self[0].timestamp - - def is_timestamped(self) -> bool: - """If first position exist, the movement is timestamped.""" - return bool(self) - - @timestamp.setter - def timestamp(self, timestamp: int | float): - """Block gaze movement timestamp setting.""" - raise ('GazeMovement timestamp is first position timestamp.') - def is_finished(self) -> bool: """Is the movement finished?""" return self.__finished @@ -552,8 +533,8 @@ class TimeStampedGazeMovements(DataFeatures.TimestampedObjectsList): def __init__(self, gaze_movements: list = []): DataFeatures.TimestampedObjectsList.__init__(self, GazeMovement, gaze_movements) - -class GazeStatus(list, DataFeatures.TimestampedObject): +@DataFeatures.timestamp +class GazeStatus(list): """Define gaze status as a list of 1 or 2 (index, GazeMovement) tuples. Parameters: @@ -561,8 +542,8 @@ class GazeStatus(list, DataFeatures.TimestampedObject): """ def __init__(self, position: GazePosition): - DataFeatures.TimestampedObject.__init__(self, timestamp=position.timestamp) - + + self.timestamp = position.timestamp self.__position = position @property |