Skip to main content

simplify combining and comparing contiguous ranges of int/floats

Project description

ABOUT

This package implements intrange and floatrange classes and a rangelist class to manage them.

intrange objects are similar to standard range objects. They have the option to be closed or not. in addition several methods are overloaded to allow arithmetic operations

a=intrange(1,20) b=intrange(4,8)

a-b evaluates to [intrange(1,3,closed=True,group=(1,)), intrange(9,20,closed=True,group=(1,))] b-a evaluates to [] b*a = a*b the intersection of a and b

a-1 = intrange(0,19,closed=True,group=(1,))

the group property allow otherwise overlapping ranges to be treated as distinct.

The attributes property allows other metadata to accompany the range object. It is however, up to the user to decide how to interpret those attributes after adding the ranges.

Example usage

The following are some sample operations

a: intrange(1,20,closed=True) b: intrange(4,8,closed=True) c: intrange(2,8,closed=True) d: intrange(2,8,closed=False) e: intrange(7,40,closed=True) a-b: [intrange(1,3,closed=True,group=(1,)), intrange(9,20,closed=True,group=(1,))] 1 in a: True 8 in b: True 12 in b: False a + b: [intrange(1,20,closed=True,group=(1,))] b + a: [intrange(1,20,closed=True,group=(1,))] a - b: [intrange(1,3,closed=True,group=(1,)), intrange(9,20,closed=True,group=(1,))] b - a: [] a * b: intrange(4,8,closed=True) b * a: intrange(4,8,closed=True) a // b : [intrange(1,3,closed=True,group=(1,)), intrange(9,20,closed=True,group=(1,))] b // a: [] b // 6: [intrange(4,5,closed=True,group=(1,)), intrange(7,8,closed=True,group=(1,))] b - c: [] b-d: [intrange(8,8,closed=True,group=(1,))] rangelist((a,e)) : [intrange(1,20,closed=True,group=(1,)), intrange(7,40,closed=True,group=(1,))]

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

range_ops-0.0.1.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

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

range_ops-0.0.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file range_ops-0.0.1.tar.gz.

File metadata

  • Download URL: range_ops-0.0.1.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for range_ops-0.0.1.tar.gz
Algorithm Hash digest
SHA256 8470b2875b727a1110b3f238118cebf8db43d69e70da28ef429f57657e45e824
MD5 aa88888e14f903f254d9ab7a7d13eec7
BLAKE2b-256 ebfad5b82aab10ed826770f4864c4c7d753efd3cbdfb1c2b333e7d1fd058d6bb

See more details on using hashes here.

File details

Details for the file range_ops-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: range_ops-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for range_ops-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c58b9a60ed7b2f5b5bbf94c968fb2372ee01627ddd1172e90760e553efdc6b05
MD5 d4cde7d86accd0dd7b3b8058384767ef
BLAKE2b-256 5d3042459500fca6cf2234da502cf97e616705865e4ca1cf476ce9db3675b034

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