Component developers should implement `_next_time` instead of the property `next_time`
Since all the required methods in a component start with an underscore (_initialize
, _update
and so on), it feels strange, that users then need to implement a property for the next time.
It should be handled as all the other method implementations (in TimeComponent
):
class TimeComponent(ITimeComponent, Component, ABC):
...
@property
def next_time(self):
"""The component's predicted simulation time of the next pulls.
Can be ``None`` if the component has no inputs.
"""
return self._next_time
def _next_time(self):
raise NotImplementedError(
f"Method `_next_time` must be implemented by all time components, but implementation is missing in {self.name}."
)
Then, the component implementation looks like this:
class Model(finam.TimeComponent):
def _next_time(self): ...
def _initialize(self): ...
def _connect(self): ...
def _update(self): ...
instead of this:
class Model(finam.TimeComponent):
@property
def next_time(self): ...
def _initialize(self): ...
def _connect(self): ...
def _update(self): ...