Skip to main content

For example, this sequence of events …

  • A: $10

  • B: $10

  • C: ($18)

  • D: ($2)

… is turned into this timeline:

A             B             C             D
|             |             |             |
|_____________|_____________|             |
|                           |             |
|           $10             |             |
|___________________________|             |
              |             |             |
              |     $8      |             |
              |_____________|_____________|
              |                           |
              |            $2             |
              |___________________________|

This lets you determine, for each balance reduction event, the events from which the balance was added. In this example, we can see that:

  • The $18 reduction in event C came from $10 of event A and $8 of B.

  • The $2 reduction in event D came entirely from event B.

Code for this example:

from refund_calculation import *

history_from_event_sequence([
    Event(time='A', delta='10'),
    Event(time='B', delta='10'),
    Event(time='C', delta='-18'),
    Event(time='D', delta='-2'),
])

# Result:
History(
    closed=(
        Closed(amount=Decimal('10'), start='A', end='C'),
        Closed(amount=Decimal('8'),  start='B', end='C'),
        Closed(amount=Decimal('2'),  start='B', end='D'),
    ),
    open=(),
    debt=Decimal('0'),
)

Metadata

Release files for refund_calculation 0.1

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

Source distribution (sdist)

Source distribution for refund_calculation 0.1
File Size Uploaded Provenance Actions
refund_calculation-0.1.tar.gz 3.7 kB Without provenance Details for refund_calculation-0.1.tar.gz

Release files / refund_calculation-0.1.tar.gz

Download URL refund_calculation-0.1.tar.gz
Size 3.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ac724f169a5542c97b15e5528671278e3d42e84ba1e24223f78e27b08cc431a8
BLAKE2b-256 checksum
How to use checksums
c9faad4b2c48a4078ad8fa20ff96483e12d9aae8e54625d14d1eb4de6a5df494
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for refund_calculation 0.1

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.

Release history Release notifications | RSS feed

This release

0.1 This release

1 release file No provenance

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