Skip to main content

Represent large intervals of numeric/datetime data with a small memory footprint.

Project description

MultInterval

Represent large intervals of numeric/datetime data in Python with a small memory footprint.

When to Use

  • Your data is a long contiguous stretches (in fixed steps) of data that is separated by few missing gaps.
  • Each data point can be compared to another, and divisble by the step factor (supports datetime/timedelta combinations)

How to Use

import multinterval as mi

# at instantiation, only a step is necessary
i = mi.MultInterval(step=5)
print(list(i))  # outputs []

# the set is fully instantiated only when there is at least one member
i.include(3)
print(list(i))  # outputs [3]


# include other compatible values, Intervals, MultIntervals
i.include(8, 13, 23) # include multiple numbers
i.include(mi.Interval(53, 68, step=5)) # include full intervals
i.include(
	mi.MultInterval(
		step=5,
		ranges=[mi.Interval(103, 113, step=5), mi.Interval(158, 193, step=5)],
	)
)
print(list(i))  # outputs [3, 8, 13, 23, 53, 58, 63, 103, 108, 158, 163, 168, 173, 178, 183, 188]


# exclude any compatible values
i.exclude(23)
i.exclude(mi.Interval(13, 108, step=5))
i.exclude(
	mi.MultInterval(
		step=5,
		ranges=[mi.Interval(53, 178, step=5)],
	)
)
print(list(i))  # outputs [3, 8, 178, 183, 188]


# the following will cause errors

# including values not in the same number line will cause an error
# i.include(7)

# including intervals on a different step
# i.include(mi.Interval(3, 9, step=3))

# including intervals that do not coincide on the same step
# i.include(mi.Interval(4, 10, step=5))

Implementation Details

  • Complete intervals are represented with a tuple of inclusive start and exclusive end.
  • Longer intervals with gaps are represented by a list of the complete intervals.

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

multinterval-0.1.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

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

multinterval-0.1.0-py3-none-any.whl (6.0 kB view details)

Uploaded Python 3

File details

Details for the file multinterval-0.1.0.tar.gz.

File metadata

  • Download URL: multinterval-0.1.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.3

File hashes

Hashes for multinterval-0.1.0.tar.gz
Algorithm Hash digest
SHA256 87fa41bcf52d663f0964f648b57f241318379757bca5948e162ddb03dd6b85be
MD5 16755794fadcabc1ab3de9d71f4754e8
BLAKE2b-256 52b964fd6afc273c7ab9f4f02e7bb55ec1acfb9ce808e58fd6f238a38a454286

See more details on using hashes here.

File details

Details for the file multinterval-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for multinterval-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a133336899bbff0a03e33d87491063542d6cc1dabed9fbbb7c4a14847ddab090
MD5 078efe39b96fcd65601dce44d82aaeaf
BLAKE2b-256 638b39dfa531d14c0e39f5a0abb0f21b0e839e211201bad02dd0952901cfc390

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