Skip to main content

RunningCalcs

A library for executing running calculations

Introduction

Instances of the RunnincCalc classes in this library can be fed one input value at a time. This allows running several calculations in a single pass over an iterator. This isn’t possible with the built-in variants of most calculations, such as max() and heapq.nlargest().

RunningCalc instances can be fed values directly, for example:

mean_rc, stddev_rc = RunningMean(), RunningStdDev()
for x in values:
    mean_rc.feed(x)
    stddev_rc.feed(x)
mean, stddev = mean_rc.value, stddev_rc.value

Additionally, the apply_in_parallel() function is supplied, which makes performing several calculations in parallel easy (and fast!). For example:

mean, stddev = apply_in_parallel([RunningMean(), RunningStdDev()], values)
five_smallest, five_largest = apply_in_parallel([RunningNSmallest(5), RunningNLargest(5)], values)

Optimizations

In addition to the basic feed() method, some RunningCalc classes also implement an optimized feedMultiple() method, which accepts a sequence of values to be processed. This allows values to be processed in chunks, allowing for faster processing in many cases.

The apply_in_parallel() function automatically splits the given iterable of input values into chunks (chunk size can be controlled via the chunk_size keyword argument). Therefore using apply_in_parallel() is both fast and easy.

Writing Your Own RunningCalc Class

  1. sub-class RunningCalc

  2. implement the __init__() and feed() methods

  3. make the calculation output value accessible via the value attribute

  4. optionally implement an optimized feedMultiple() method Note: the RunningCalc base class includes a default naive implementation of feedMultiple()

Metadata

Release files for RunningCalcs 0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for RunningCalcs 0.4
File Size Uploaded Provenance
RunningCalcs-0.4.zip 6.6 kB Without provenance Details

Release files / RunningCalcs-0.4.zip

Download URL RunningCalcs-0.4.zip
Size 6.6 kB
Tags Source
SHA-256 checksum
How to use checksums
f763b0900de2922c0b31dfcead5e132050895285f709ccf6eee84dcaa56def2b
BLAKE2b-256 checksum
How to use checksums
b1d7eba1b3f001b59083d295219494af9514849ded5dbf19421ac777cac87087
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for RunningCalcs 0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page