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.1.tar.gz
.
File metadata
- Download URL: intervalues-0.1.1.tar.gz
- Upload date:
- Size: 19.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 PyPy/7.3.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1735d5f2916d184aa98c3339a5e31524ff651c0be5747d5449db82742753fa27 |
|
MD5 | a8d682bf6353f968678d4fbfaf370131 |
|
BLAKE2b-256 | c55a7c057aa8bb4470d16c697d0e71ce80e5304c25998ce6e6ac2a1f414af1c7 |
File details
Details for the file intervalues-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: intervalues-0.1.1-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 | 0f5fcf409a81b61b8b9d279f76b123ea0d7f251734ba264cb66ebd84d6d4d768 |
|
MD5 | a3a48147570d038eaa2de1752ce57316 |
|
BLAKE2b-256 | 0ffdb314fbace6f764375024af17da813908243faad83e29a2ee77323c20b1f0 |