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.0.3.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

intervalues-0.0.3-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for intervalues-0.0.3.tar.gz
Algorithm Hash digest
SHA256 89b8f30cfc703a453e2aa81eb24b1a996da77c96badce1cd2891309f36246b79
MD5 a61c14777d4d3e5d584885b1050474be
BLAKE2b-256 5caf1e185dca980f9eed51376e537bda530c5719605c4ab00feb54b5f181af0b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: intervalues-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 15.2 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.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f8839b9fc647a3c620277da5e4de0efb7fd6ffa7ad1899e82e87c15b4311fec7
MD5 4c8476d5f7147d712e9000bd55abee94
BLAKE2b-256 3e102e7a7385d385e6657f02e60b7c6d3275435529a8aa499fe42dbec7afc65d

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