Efficient combining of intervals of numbers.
Project description
intervalues
Efficient combining of intervals of numbers for various applications.
Getting started
To download and install the most recent version, use pip:
pip install intervalues
.
Then, consider this simple example for how to use it:
import intervalues as iv
interval_a = iv.BaseInterval(0, 2) # Interval from 0 to 2
interval_b = iv.BaseInterval(1, 3) # Another interval, from 1 to 3
combined = iv.IntervalMeter([interval_a, interval_b])
combined # -> IntervalMeter:{BaseInterval[0;0.5]: 1, BaseInterval[0.5;1]: 2, BaseInterval[1;1.5]: 1}
combined[1.5] # -> 2
For more extensive examples, see the examples folder (which, admittedly, needs to be improved and extended).
Motivation
This package will be useful in the following cases:
- If you have too many intervals and can't easily see which value is featured the most across them.
- If you have a large number of integers to keep track of, and you need to do this more memory efficient than a list of all individual numbers
- If you have a list of continuous intervals that need to be combined
- If you want to use a collection of intervals for statistical purposes, like sampling a random number from it
Features
Contains the following classes:
- IntervalSet (optimized towards keeping track of coverage)
- IntervalList (unstructured collection - faster to create, and can apply FIFO-type decisions)
- IntervalCounter (optimized towards tracking counts, integer-valued and positive)
- IntervalMeter (optimized towards tracking values assigned to individual numbers)
- IntervalPdf (normalized IntervalMeter for statistical purposes)
Currently only continuous intervals of floats are supported, for which the distinction between open and closed intervals is ignored. In the future, this distinction will be taken into account, as well as only considering integers or otherwise discrete intervals (only odd numbers, or only multiples of 0.25, etc.)
Extended future wish list
- As stated above, conversion of continuous intervals to discrete intervals
- As stated above, the distinction between open and closed intervals.
- Allowing for infinity as upper bound (or -infinity as lower bound)
- Sampling from any of these interval collections, where applicable
- Multi-dimensional intervals (e.g. regions, volumes, etc)
- Fully documented and type-hinted code when the codebase is more stable
- Using intervals for more generic (e.g. non-numeric) tracking of properties: [0,2] is green, [1.8,2.5] is sweet, etc.
- IntervalFunctions: getting different functional outputs for different intervals
- Replacing core functionality with C or Rust bindings where this is most relevant for gains in practice
- Add more examples, and improve the existing ones.
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
File details
Details for the file intervalues-0.1.0.tar.gz
.
File metadata
- Download URL: intervalues-0.1.0.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 PyPy/7.3.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8947e45affeb6666212f9a37a7c9b68021aba1ef608f799c7899fd928bbc196d |
|
MD5 | 433288628b90d72d6a4412cdf12493c5 |
|
BLAKE2b-256 | 3868b11104c6f794bf3a8d4077819f732e2d5fad243f10e7ad8d353860de8085 |
File details
Details for the file intervalues-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: intervalues-0.1.0-py3-none-any.whl
- Upload date:
- Size: 17.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 PyPy/7.3.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 836f8ff9a5b0565b9271551b7a5b9b732e131b0451b8754d6a33952951cf4bcd |
|
MD5 | 33235f1d23f69d047980c20e81261244 |
|
BLAKE2b-256 | 496b22390f38a50e7f6f942531e0517acd10636aa5b15c08ac8661c709f47846 |