A dictionary keyed by ranges of floating point numbers
Project description
Introduction
interval provides a dictionary-like class keyed by ranges of floating-point numbers.
Each value of the dictionary applies for any key value within the numeric range.
Later entries into the dictionary can partially or completely replace earlier values.
interval is a product of the PDS Ring-Moon Systems Node.
Note that this package is deprecated in favor of the portion module.
Eventually this package may be removed entirely.
Installation
The interval module is available via the rms-interval package on PyPI and can be installed with:
pip install rms-interval
Getting Started
The interval module provides the Interval class, which behaves like a dictionary
keyed by ranges of floating-point numbers. You can create an interval with a specific
range, or use the default range from negative infinity to positive infinity.
Basic operation is as follows:
from interval import Interval
# Create an interval from 0 to 100
interval = Interval(0, 100)
# Set values for different ranges
interval[(11, 30)] = 1.5
interval[(31, 60)] = 2.5
interval[(61, 90)] = 3.5
# Access values at specific points
print(interval[15]) # Prints: 1.5
print(interval[50]) # Prints: 2.5
print(interval[75]) # Prints: 3.5
# Get all values within a range
print(interval[(0, 100)]) # Prints: [None, 1.5, 2.5, 3.5]
# Overlay a new value that partially replaces existing ones
interval[(15, 45)] = 4.5
print(interval[20]) # Prints: 4.5 (replaces 1.5 in this range)
print(interval[50]) # Prints: 2.5 (unchanged)
The interval class handles overlapping ranges by giving precedence to later entries. When you query a range, you get all unique values that were set within that range, ordered by their insertion sequence.
Details of the class are available in the module documentation.
Contributing
Information on contributing to this package can be found in the Contributing Guide.
Links
Licensing
This code is licensed under the Apache License v2.0.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rms_interval-1.0.0.tar.gz.
File metadata
- Download URL: rms_interval-1.0.0.tar.gz
- Upload date:
- Size: 22.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ceea36972bc0ab0e079dc0602d090079b5e6a1cf3620b164a7eb1ba555092c93
|
|
| MD5 |
27cf865447e8ac773726226129d2c022
|
|
| BLAKE2b-256 |
4bb4fe3722f7eef3cbcf4f686e908e9a8eb30eb7e909cd07190b4e4474889f2d
|
File details
Details for the file rms_interval-1.0.0-py3-none-any.whl.
File metadata
- Download URL: rms_interval-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
df2d72638984e3cec11a9a24b749dab4631ab9a45ba2908ff045364ab13b7820
|
|
| MD5 |
7f7c7393bcf913d54d47bd0ab570dc89
|
|
| BLAKE2b-256 |
aac2cf8dc4c83e12747c0d7d3221cfd646e183e9f4ad59488060424074adc4f1
|