MultInterval
Represent large intervals of numeric/datetime data in Python with a small memory footprint.
When to Use
- Your data is a long contiguous stretches (in fixed steps) of data that is separated by few missing gaps.
- Each data point can be compared to another, and divisble by the step factor (supports datetime/timedelta combinations)
How to Use
import multinterval as mi
# at instantiation, only a step is necessary
i = mi.MultInterval(step=5)
print(list(i)) # outputs []
# the set is fully instantiated only when there is at least one member
i.include(3)
print(list(i)) # outputs [3]
# include other compatible values, Intervals, MultIntervals
i.include(8, 13, 23) # include multiple numbers
i.include(mi.Interval(53, 68, step=5)) # include full intervals
i.include(
mi.MultInterval(
step=5,
ranges=[mi.Interval(103, 113, step=5), mi.Interval(158, 193, step=5)],
)
)
print(list(i)) # outputs [3, 8, 13, 23, 53, 58, 63, 103, 108, 158, 163, 168, 173, 178, 183, 188]
# exclude any compatible values
i.exclude(23)
i.exclude(mi.Interval(13, 108, step=5))
i.exclude(
mi.MultInterval(
step=5,
ranges=[mi.Interval(53, 178, step=5)],
)
)
print(list(i)) # outputs [3, 8, 178, 183, 188]
# the following will cause errors
# including values not in the same number line will cause an error
# i.include(7)
# including intervals on a different step
# i.include(mi.Interval(3, 9, step=3))
# including intervals that do not coincide on the same step
# i.include(mi.Interval(4, 10, step=5))
Implementation Details
- Complete intervals are represented with a tuple of inclusive start and exclusive end.
- Longer intervals with gaps are represented by a list of the complete intervals.
Release files for multinterval 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| multinterval-0.1.0.tar.gz | 5.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| multinterval-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.3 kB
Release files / multinterval-0.1.0.tar.gz
| Download URL | multinterval-0.1.0.tar.gz |
|---|---|
| Size | 5.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
87fa41bcf52d663f0964f648b57f241318379757bca5948e162ddb03dd6b85be
|
|
BLAKE2b-256 checksum How to use checksums |
52b964fd6afc273c7ab9f4f02e7bb55ec1acfb9ce808e58fd6f238a38a454286
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.3
|
Release files / multinterval-0.1.0-py3-none-any.whl
| Download URL | multinterval-0.1.0-py3-none-any.whl |
|---|---|
| Size | 6.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a133336899bbff0a03e33d87491063542d6cc1dabed9fbbb7c4a14847ddab090
|
|
BLAKE2b-256 checksum How to use checksums |
638b39dfa531d14c0e39f5a0abb0f21b0e839e211201bad02dd0952901cfc390
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.6.3
|