Skip to main content

A small flexible interval package

Project description

pynterval

A small python module to handle numeric intervals

pip install pynterval
>>> from pynterval import Interval
>>> 
>>> my_interval = Interval(0, 5)
>>> vals = (0, 4, 5, Interval(2.1, 3.4), Interval(0, 5), Interval(0, 5, 3))
>>> [val in my_interval for val in vals]
[True, True, False, True, True, False]
>>> 
>>> Interval()
Interval: {}
>>> Interval().empty
True
>>> Interval(4)
Interval: {4}

*** Works also with many other comparable objects ***

>>> from pynterval import Interval
>>> import pint
>>> ureg = pint.UnitRegistry()
>>> 
>>> my_interval = Interval(0 * ureg.mm, 15 * ureg.cm)
>>> (1 * ureg.inch) in my_interval
True
>>> 
>>> my_rightunbounded_interval = Interval(100 * ureg.mm, float('inf'))
>>> (5 * ureg.cm) in my_rightunbounded_interval
False
>>> (5 * ureg.lightyear) in my_rightunbounded_interval
True

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

pynterval-0.3.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pynterval-0.3-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

Details for the file pynterval-0.3.tar.gz.

File metadata

  • Download URL: pynterval-0.3.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1

File hashes

Hashes for pynterval-0.3.tar.gz
Algorithm Hash digest
SHA256 316bdf612070a6fc5456f0fed9ff79365207e0d9aa515d0f889a184d2434552f
MD5 618b5c05d8465e384d0ef33df181970b
BLAKE2b-256 551fcc0eede4a09b3ab720bbfa8c581a34e0fc449ef6353696b4aea37638f2bf

See more details on using hashes here.

File details

Details for the file pynterval-0.3-py3-none-any.whl.

File metadata

  • Download URL: pynterval-0.3-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/3.10.1 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.60.0 CPython/3.9.1

File hashes

Hashes for pynterval-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 06dabf714bf299fa021f74437ba72857ecf7689adc4f9f73bb70a7b5e2e22b88
MD5 55f9c1c23c33c1ce7490219ef25fbb04
BLAKE2b-256 0d965c288da1c66a5f760ba03c95f5273ba4a7a2e29e6ddfe42139586ae217be

See more details on using hashes here.

Supported by

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