From 054b59a68d38464880580315970ecc936581d16d Mon Sep 17 00:00:00 2001 From: Elton Cardoso do Nascimento <43186596+EltonCN@users.noreply.github.com> Date: Fri, 20 Sep 2024 16:07:56 -0300 Subject: [PATCH] Fix Memory/MO data types timestamp and id float->int --- src/cst_python/core/entities/memory.py | 8 ++++---- src/cst_python/core/entities/memory_object.py | 18 +++++++++--------- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/cst_python/core/entities/memory.py b/src/cst_python/core/entities/memory.py index 30e0160..bbaa0a6 100644 --- a/src/cst_python/core/entities/memory.py +++ b/src/cst_python/core/entities/memory.py @@ -38,7 +38,7 @@ def set_evaluation(self, evaluation:float) -> None: #@alias.alias("getTimestamp") @abc.abstractmethod - def get_timestamp(self) -> float: + def get_timestamp(self) -> int: ... #@alias.alias("addMemoryObserver") @@ -53,17 +53,17 @@ def remove_memory_observer(self, observer:MemoryObserver) -> None: #@alias.alias("getId") @abc.abstractmethod - def get_id(self) -> float: + def get_id(self) -> int: ... #@alias.alias("setId") @abc.abstractmethod - def set_id(self, memory_id:float) -> None: + def set_id(self, memory_id:int) -> None: ... #@alias.alias("getTimestamp") @abc.abstractmethod - def get_timestamp(self) -> float: + def get_timestamp(self) -> int: ... diff --git a/src/cst_python/core/entities/memory_object.py b/src/cst_python/core/entities/memory_object.py index 9ab855d..48a8160 100644 --- a/src/cst_python/core/entities/memory_object.py +++ b/src/cst_python/core/entities/memory_object.py @@ -10,8 +10,8 @@ class MemoryObject(Memory): def __init__(self) -> None: - self._id = 0.0 - self._timestamp = 0.0 + self._id = 0 + self._timestamp = 0 self._evaluation = 0.0 self._info : Any = None self._name = "" @@ -24,10 +24,10 @@ def __getstate__(self) -> object: return state - def get_id(self) -> float: + def get_id(self) -> int: return self._id - def set_id(self, memory_id: float) -> None: + def set_id(self, memory_id: int) -> None: self._id = memory_id def get_info(self) -> Any: @@ -35,7 +35,7 @@ def get_info(self) -> Any: def set_info(self, value: Any) -> int: self._info = value - self._timestamp = time.time() + self._timestamp = int(time.time()*1000) self._notify_memory_observers() return -1 @@ -47,16 +47,16 @@ def _notify_memory_observers(self) -> None: def update_info(self, info:Any) -> None: self.set_info(info) - def get_timestamp(self) -> float: + def get_timestamp(self) -> int: return self._timestamp @property - def timestamp(self) -> float: + def timestamp(self) -> int: return self._timestamp #@alias.alias("setTimestamp") @timestamp.setter - def timestamp(self, value:float) -> None: + def timestamp(self, value:int) -> None: self._timestamp = value def get_name(self) -> str: @@ -72,7 +72,7 @@ def get_evaluation(self) -> float: return self._evaluation def set_evaluation(self, evaluation: float) -> None: - return self._evaluation + self._evaluation = evaluation #@alias.alias("toString", "to_string") def __str__(self) -> str: