diff --git a/README.md b/README.md index d498ac9..6c93345 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,11 @@ ===================================== generator=datazen version=3.1.2 - hash=1cdc07131261518d6adc3cc3b858a4e5 + hash=c8539167d87cd90bab3348640cfcc01d ===================================== --> -# vcorelib ([2.1.0](https://pypi.org/project/vcorelib/)) +# vcorelib ([2.1.1](https://pypi.org/project/vcorelib/)) [![python](https://img.shields.io/pypi/pyversions/vcorelib.svg)](https://pypi.org/project/vcorelib/) ![Build Status](https://github.com/vkottler/vcorelib/workflows/Python%20Package/badge.svg) diff --git a/local/variables/package.yaml b/local/variables/package.yaml index cbd7ae0..2dc1b19 100644 --- a/local/variables/package.yaml +++ b/local/variables/package.yaml @@ -1,4 +1,4 @@ --- major: 2 minor: 1 -patch: 0 +patch: 1 diff --git a/pyproject.toml b/pyproject.toml index a60293a..c0f6740 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta:__legacy__" [project] name = "vcorelib" -version = "2.1.0" +version = "2.1.1" description = "A collection of core Python utilities." readme = "README.md" requires-python = ">=3.8" diff --git a/vcorelib/__init__.py b/vcorelib/__init__.py index 5b2a35d..fd57188 100644 --- a/vcorelib/__init__.py +++ b/vcorelib/__init__.py @@ -1,7 +1,7 @@ # ===================================== # generator=datazen # version=3.1.2 -# hash=f10b2b08bda3a1c912bec72ab1620fde +# hash=755514cb838cd49df3f095036c06cce4 # ===================================== """ @@ -10,7 +10,7 @@ DESCRIPTION = "A collection of core Python utilities." PKG_NAME = "vcorelib" -VERSION = "2.1.0" +VERSION = "2.1.1" # vcorelib-specific content. DEFAULT_INDENT = 2 diff --git a/vcorelib/math/analysis/rate/__init__.py b/vcorelib/math/analysis/rate/__init__.py index b0bf731..1f46748 100644 --- a/vcorelib/math/analysis/rate/__init__.py +++ b/vcorelib/math/analysis/rate/__init__.py @@ -43,19 +43,13 @@ def max(self) -> float: """An accessor for the underlying max.""" return self.average.max - def __call__(self, time_ns: int = None, value: float = 1.0) -> float: - """ - Submit new data to the rate tracker. If this function is called with - default arguments, the returned value will reflect the rate that this - method is being called in hertz. - """ + def poll(self, time_ns: int = None) -> float: + """Siphon accumulated time and update rate tracking.""" # Use a default time if one wasn't provided. if time_ns is None: time_ns = _default_time_ns() - self.accumulated += value - # Only start tracking when a second data point is encountered. if self.prev_time_ns != 0 and time_ns > self.prev_time_ns: # Consider 'value' as the amount of change since the last data @@ -66,8 +60,19 @@ def __call__(self, time_ns: int = None, value: float = 1.0) -> float: self.accumulated = 0 self.prev_time_ns = time_ns + return self.average.value + def __call__(self, time_ns: int = None, value: float = 1.0) -> float: + """ + Submit new data to the rate tracker. If this function is called with + default arguments, the returned value will reflect the rate that this + method is being called in hertz. + """ + + self.accumulated += value + return self.poll(time_ns=time_ns) + def with_dt(self, delta_s: float, value: float = 1.0) -> float: """Update this rate by directly providing the delta-time value.""" return self.average(value / delta_s)