Skip to main content

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

intervalues-0.2.1.tar.gz (23.5 kB view details)

Uploaded Source

Built Distribution

intervalues-0.2.1-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

File details

Details for the file intervalues-0.2.1.tar.gz.

File metadata

  • Download URL: intervalues-0.2.1.tar.gz
  • Upload date:
  • Size: 23.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 PyPy/7.3.16

File hashes

Hashes for intervalues-0.2.1.tar.gz
Algorithm Hash digest
SHA256 1bd65a94a176aee42db2f47364e3c1d9480f579fba5468efe3f7ffee4b4c9f80
MD5 fdb456673038e43ed1bfc5143f282f6b
BLAKE2b-256 4bfdec8c2e3bdb7a1ed04027e09d7f85486111514bf7a75c81e3b24e56188258

See more details on using hashes here.

File details

Details for the file intervalues-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: intervalues-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 PyPy/7.3.16

File hashes

Hashes for intervalues-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 72dc8f4c2cc6fee9dcf7349636fefe27ce4ac45e0742b6424633d32d06f4f0a6
MD5 f03c3dbdbd9b247ad97acc5c9992caf1
BLAKE2b-256 4db65c6f08be44c3a3741110d199d067a82f90102b3f02ed8d169a0f5f2b9acd

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page