intervalues
intervalues combines numeric intervals and tracks coverage or values across them. It supports continuous intervals, discrete intervals with a configurable step, datetime coordinates with elapsed timedelta lengths and steps, and collection types for different use cases.
Installation
pip install intervalues
The optional Rust extension accelerates interval combination for larger inputs. Without it, the package and its Rust-named helper continue to work using the Python implementation.
Quick start
import intervalues as iv
interval_a = iv.BaseInterval(0, 2)
interval_b = iv.BaseInterval(1, 3)
meter = iv.IntervalMeter([interval_a, interval_b])
print(meter)
# IntervalMeter:{BaseInterval[0;1]: 1, BaseInterval[1;2]: 2, BaseInterval[2;3]: 1}
print(meter[1.5]) # 2: the overlapping region has a combined value of 2
BaseInterval(start, stop, value=1) represents a continuous interval. BaseDiscreteInterval(start, stop, step=1, value=1) represents the points from start through stop at the given step; the stop is included when it aligns with the step. For example:
points = iv.BaseDiscreteInterval(0, 4, step=2)
print(list(points)) # [(0, 1), (2, 1), (4, 1)]
For discrete probability mass, convert a discrete interval to an IntervalPmf:
pmf = points.as_pmf()
draws = pmf.sample(3)
Continuous interval membership includes both endpoints; open versus closed boundaries are not configurable.
For constructor forms, interval utilities, collection semantics, mutation, conversions, and continuous-versus-discrete behavior, see the intervals and collections guide.
Choose an interval type
IntervalMeteris the most flexible overlapping collection type. It combines values over overlapping regions and supports arbitrary real-valued weights, including fractional and negative values.IntervalCounteris a specialized choice when you only need non-negative integer coverage counts.IntervalSetis a specialized choice when you only need to know which regions are covered; it discards overlap multiplicity and values.IntervalListretains each original interval, its order, and duplicates.IntervalPdfrepresents a continuous probability distribution over intervals.IntervalPmfrepresents probability mass on discrete points.
Choose IntervalMeter when you need to preserve or combine interval values.
It supports fractional and negative weights, which are added where intervals
overlap:
meter = iv.IntervalMeter([
iv.BaseInterval(0, 3, value=2.5),
iv.BaseInterval(1, 2, value=-1.0),
])
print(meter[0.5]) # 2.5
print(meter[1.5]) # 1.5: 2.5 + -1.0
Use IntervalCounter or IntervalSet when their narrower counting or
coverage semantics are a better fit. For example, the same two overlapping
intervals form one covered region in a set, while the meter and counter retain
the overlap count:
covered = iv.IntervalSet([interval_a, interval_b])
counter = iv.IntervalCounter([interval_a, interval_b])
print(covered) # IntervalSet:{BaseInterval[0;3]}
print(counter[1.5]) # 2
Use IntervalList when each interval is a separate record and you need to keep
its order or identity, rather than combining overlapping intervals. For
example, a schedule may contain separate bookings with the same time range:
bookings = iv.IntervalList([
iv.BaseInterval(9, 10),
iv.BaseInterval(9.5, 11),
iv.BaseInterval(9, 10), # A second booking with the same time range
])
print(list(bookings))
# [BaseInterval[9;10], BaseInterval[9.5;11], BaseInterval[9;10]]
print(bookings[9.75]) # 3: all three bookings cover this time
For example, an IntervalPdf can describe uncertainty over a continuous range:
pdf = iv.IntervalPdf(iv.BaseInterval(0, 10))
print(pdf.mean(), pdf.sample(3))
IntervalPdf and IntervalPmf support additional probability queries,
summaries, comparisons, and sample-based diagnostics. See the
probability distributions guide for the API, examples,
and statistical assumptions.
Rust acceleration
Use the Rust implementation explicitly with combine_via_rust(intervals) or IntervalMeter(intervals, use_rust=True). Rust combination converts numeric coordinates to integers by default; set nr_digits to retain a chosen number of decimal places. This quantization can affect results. If the extension is unavailable, the Python implementation is used and retains the original coordinate precision, so nr_digits has no effect. Datetime intervals always use the Python combiner; they are never converted to timestamps or passed to Rust, and nr_digits has no effect for them.
Examples
Runnable scenarios are in examples/:
example_count_criteria_met.pycounts how many criteria cover each value in a range.example_airfield_coverage.pyestimates runway capacity from aircraft schedules.example_student_regulations_impact.pycombines discrete student-number ranges affected by regulations.example_solar_market_dispatch.pyresolves synthetic solar setpoints across day-ahead, intraday, and live prices on 15-minute UTC intervals.example_maturin.pycompares Python and Rust combination timings.
Run an example from the repository root with python examples/example_count_criteria_met.py (replace the filename to run another). The timing example uses repeatable inputs, excludes setup and warm-up time, and reports median timings; adjust its workload with python examples/example_maturin.py --sizes 100 1000 10000 --repeats 5. Rust timings are shown only when the extension is installed.
Development
The development tools are declared in pyproject.toml and locked in
uv.lock. Install uv, then sync the development
environment from the repository root:
uv sync --locked --no-install-project --group dev
Run tests and the configured type check with:
uv run --no-sync python -m pytest
uv run --no-sync mypy intervalues tests/test_public_type_contract.py
Building the package with its declared build dependencies builds the Rust extension; importing and using the package does not require that extension.
Type annotations are included in the package for static type checkers.
Maintainers can follow the release procedure to build, validate, and publish a release through TestPyPI before production PyPI.
Metadata
Release files for intervalues 0.4.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 | Provenance | |
|---|---|---|---|---|
| intervalues-0.4.0.tar.gz | 102.3 kB | With provenance | Details |
Built distributions (wheels)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| intervalues-0.4.0-py3-none-any.whl | Python 3 | none | any | Details |
| intervalues-0.4.0-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | PyPy 3.11 | PyPy 3.11 7.3 | Linux glibc 2.17+ x86-64 | Details |
| intervalues-0.4.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl | CPython 3.10 | abi3 | Linux glibc 2.17+ x86-64 | Details |
Total release size: 783.0 kB
Release files / intervalues-0.4.0.tar.gz
| Download URL | intervalues-0.4.0.tar.gz |
|---|---|
| Size | 102.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8ebce51456d81acb3093203e1dbaf2feb3715e71f611d6381580860ede0e8b1c
|
|
BLAKE2b-256 checksum How to use checksums |
34b9a03c4cbc7984e37cd6407ef8edf701708b859a44e08cb5744475ed1c0745
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logRelease files / intervalues-0.4.0-py3-none-any.whl
| Download URL | intervalues-0.4.0-py3-none-any.whl |
|---|---|
| Size | 59.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e3c25ce3c22793762f0662c8cd6bf0f6ee0cbd1815cea65a5ade0feab0d97103
|
|
BLAKE2b-256 checksum How to use checksums |
f2c17694eadbda7de1e4f554cef78996bdc344f39dc3964fde9081b3f4971f43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logRelease files / intervalues-0.4.0-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | intervalues-0.4.0-pp311-pypy311_pp73-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 310.6 kB |
| Tags | Linux glibc 2.17+ x86-64 PyPy 3.11 PyPy 3.11 7.3 |
|
SHA-256 checksum How to use checksums |
5795955a8f25d708df0733d8b3df6775da606981323d03eedada8495b1b6ecf6
|
|
BLAKE2b-256 checksum How to use checksums |
9cbff1e21ed65dcd3e8a315775138013fb1983bf43a777d2513de8a80a46dd87
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logRelease files / intervalues-0.4.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
| Download URL | intervalues-0.4.0-cp310-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl |
|---|---|
| Size | 311.0 kB |
| Tags | CPython 3.10 Linux glibc 2.17+ x86-64 abi3 |
|
SHA-256 checksum How to use checksums |
5f2790872b4784b5c29eadfa08b397e47c113b8a42b265dacc057f6cc585b556
|
|
BLAKE2b-256 checksum How to use checksums |
c423c08f06a30f81e39d1ee1ea40c622db4170a5ffcba5abc00ca9aafa27bff3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logSecurity for intervalues 0.4.0
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.
Full provenance
All 4 files in this release have been uploaded with provenance metadata.
Attestation for intervalues-0.4.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 23, 2026.
Transparency logA 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.