Weave multiple streams of intervals into combinations
Project description
eventweave
Eventweave is a lightweight Python utility that groups overlapping events into chronological combinations. It is useful for temporal reasoning and event sourcing, allowing you to analyze and visualize the relationships between events that occur simultaneously.
Features
- Accepts any iterable of events with user-defined start and end times
- Yields sets of events that are simultaneously active at some point in time
- Handles edge cases for back-to-back, non-overlapping intervals
- Runs in
O(n log n)time andO(n)space
Installation
This project is self-contained with no dependencies beyond the Python standard library.
You can install it using pip:
python -m pip install eventweave
Supported for Python 3.13 and above.
Example Usage
Define your events and a key function:
>>> from eventweave import interweave
>>>
>>> events = [
... ("A", (1, 4)),
... ("B", (2, 5)),
... ("C", (5, 6)),
... ]
>>>
>>> def key(event):
... return event[1]
Use interweave to iterate over overlapping combinations:
>>> result = list(interweave(events, key))
>>> expected = [
... {('A', (1, 4))},
... {('A', (1, 4)), ('B', (2, 5))},
... {('B', (2, 5))},
... {('C', (5, 6))},
... ]
>>> assert result == expected
Clarification of Overlapping Events
If one event ends at time T and another begins at time T, they are not
considered overlapping. The model assumes the starting event ends just after
T to preserve strict separation of events that merely touch.
This handling of edge cases can lead to surprising results in certain situations. For example, if a long-running event spans two shorter events - where the first ends exactly when the second starts - an additional combination may currently be produced that contains only the long-running event. This behavior may change in future versions.
Currently, instantaneous events - where the start and end times are the same - are not supported. Support will be added once their semantics are clearly defined.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eventweave-0.3.0.tar.gz.
File metadata
- Download URL: eventweave-0.3.0.tar.gz
- Upload date:
- Size: 15.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f5ae3776fb079061619bd7ac94edb9d53e1ac088830e277f67c2aa46771cddb0
|
|
| MD5 |
a1a917387a1063b92b8781a4d9f2505d
|
|
| BLAKE2b-256 |
5982c94321819bf841cb98c6a9a9a162674d6b0f6cd70b7b01bbe867a1c57dfb
|
Provenance
The following attestation bundles were made for eventweave-0.3.0.tar.gz:
Publisher:
python-publish.yml on MaxG87/eventweave
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eventweave-0.3.0.tar.gz -
Subject digest:
f5ae3776fb079061619bd7ac94edb9d53e1ac088830e277f67c2aa46771cddb0 - Sigstore transparency entry: 223892946
- Sigstore integration time:
-
Permalink:
MaxG87/eventweave@42986360d3f69b252466f89919e0621352978399 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/MaxG87
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@42986360d3f69b252466f89919e0621352978399 -
Trigger Event:
release
-
Statement type:
File details
Details for the file eventweave-0.3.0-py3-none-any.whl.
File metadata
- Download URL: eventweave-0.3.0-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
38d11b64dbafd1269c178c93038537bb08e957c1ab800bd2ac62e9fee91e39ef
|
|
| MD5 |
593618ce7ad2e7065a028b244b85967f
|
|
| BLAKE2b-256 |
b232854ed8e6fae8f7485a3ed9720c43b7252421a6cd0b7196718c25ec5e7f03
|
Provenance
The following attestation bundles were made for eventweave-0.3.0-py3-none-any.whl:
Publisher:
python-publish.yml on MaxG87/eventweave
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eventweave-0.3.0-py3-none-any.whl -
Subject digest:
38d11b64dbafd1269c178c93038537bb08e957c1ab800bd2ac62e9fee91e39ef - Sigstore transparency entry: 223892949
- Sigstore integration time:
-
Permalink:
MaxG87/eventweave@42986360d3f69b252466f89919e0621352978399 -
Branch / Tag:
refs/tags/v0.3.0 - Owner: https://github.com/MaxG87
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@42986360d3f69b252466f89919e0621352978399 -
Trigger Event:
release
-
Statement type: