From aca8fb6c509b1f296cf0c94a0554969c076ab57b Mon Sep 17 00:00:00 2001 From: nardew <28791551+nardew@users.noreply.github.com> Date: Sun, 31 Mar 2024 23:50:22 +0200 Subject: [PATCH] doc --- src/talipp/indicators/Indicator.py | 60 ++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 12 deletions(-) diff --git a/src/talipp/indicators/Indicator.py b/src/talipp/indicators/Indicator.py index 1e2ab2b..794ef07 100644 --- a/src/talipp/indicators/Indicator.py +++ b/src/talipp/indicators/Indicator.py @@ -13,6 +13,14 @@ class Indicator(Sequence): + """Base indicator class. + + Args: + input_modifier: Input modifier. + output_value_type: Output value type. + input_sampling: Input sampling type. + """ + __metaclass__ = ABCMeta def __init__(self, @@ -67,6 +75,14 @@ def initialize(self, input_values: ListAny = None, input_indicator: 'Indicator' input_indicator.add_output_listener(self) def add_input_value(self, value: Any) -> None: + """**Deprecated.** Use [add][talipp.indicators.Indicator.Indicator.add] method instead. + + Add a new input value. + + Args: + value: Value to be added. + """ + warn('This method is deprecated and will be removed in the next major version. ' 'Please use add(...) method with the same signature instead.', DeprecationWarning, @@ -74,9 +90,12 @@ def add_input_value(self, value: Any) -> None: return self.add(value) def add(self, value: Any) -> None: + """Add a new input value. + + Args: + value: Value to be added. """ - add - """ + if (self.input_sampler is not None and has_valid_values(self.input_values) and self.input_sampler.is_same_period(value, self.input_values[-1])): @@ -107,6 +126,14 @@ def add(self, value: Any) -> None: listener.add(new_value) def update_input_value(self, value: Any) -> None: + """**Deprecated.** Use [update][talipp.indicators.Indicator.Indicator.update] method instead. + + Update the last input value. + + Args: + value: Value to be used. + """ + warn('This method is deprecated and will be removed in the next major version. ' 'Please use update(...) method with the same signature instead.', DeprecationWarning, @@ -114,13 +141,21 @@ def update_input_value(self, value: Any) -> None: return self.update(value) def update(self, value: Any) -> None: + """Update the last input value. + + Args: + value: Value to be used. """ - update - """ + self.remove() self.add(value) def remove_input_value(self) -> None: + """**Deprecated.** Use [remove][talipp.indicators.Indicator.Indicator.remove] method instead. + + Remove the last input value. + """ + warn('This method is deprecated and will be removed in the next major version. ' 'Please use remove(...) method with the same signature instead.', DeprecationWarning, @@ -128,9 +163,8 @@ def remove_input_value(self) -> None: return self.remove() def remove(self) -> None: - """ - remove - """ + """Remove the last input value.""" + for sub_indicator in self.sub_indicators: sub_indicator.remove() @@ -162,9 +196,8 @@ def _remove_custom(self) -> None: pass def remove_all(self) -> None: - """ - remova_all - """ + """Remove all input values.""" + for sub_indicator in self.sub_indicators: sub_indicator.remove_all() @@ -186,9 +219,12 @@ def _remove_all_custom(self) -> None: pass def purge_oldest(self, size: int) -> None: + """Purge old input values. + + Args: + size: number of oldest input values to be purged. """ - purge_oldest - """ + for sub_indicator in self.sub_indicators: sub_indicator.purge_oldest(size)