Name | drange JSON |
Version |
0.1.0
JSON |
| download |
home_page | None |
Summary | Discrete interval storage and algebra on integers (allowing for positive and negative infinity), stored as coalesced intervals. |
upload_time | 2025-09-01 17:21:43 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | MIT License
Copyright (c) 2025 YOUR NAME
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to do so, subject to the
following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. |
keywords |
coalesced
discrete
infinite
integers
interval
ranges
set
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# drange
Discrete interval algebra on **integers** (with +/- infinity), stored as coalesced runs.
- Fast set-like operations over huge or infinite sets of integers.
- Canonical internal form: sorted, disjoint, adjacency-merged **closed** intervals.
- Human-readable serialization with simple round-trips.
- Hashable, fully typed, and tested.
> Examples:
([1:3],[7:9]) # {1,2,3,7,8,9}
() # empty
([<:>]) # universal
([<:5],[7:12]) # negative infinity to 5, plus 7 through 12
([-10:>]) # all naturals from -10 to positive infinity
(4,5,10,20,[22:25]) # singletons amid runs. Note 4 and 5
([4:5],10,20,[22:25]) # [4:5] would also be valid
---
## Install
```bash
pip install drange
## How-tos
### Import
from drange.interval_set import IntervalSet
### Build from disparate sources:
A = IntervalSet.from_items([1,2,2,3,10,11,12]) # -> ([1:3],[10:12])
B = IntervalSet.from_string("([<:0],[100:>])")
### Merge adjacent and overlapping ranges:
A = IntervalSet.from_string("([1:3],[4:6])")
assert A.to_string() == "([1:6])"
### Compute complement within a finite window
S = IntervalSet.from_string("([2:5],[9:10])")
neg = ~S # -> ([<:1],[6:8],[11:>])
list_not_S = list(neg.iter_values(0,12)) # -> [0,1,6,7,8,11,12]
S_not = IntervalSet.from_items(list_not_s) # -> (0,1,[6:8],11,12)
### Subset checks (allowing infinities)
A = IntervalSet.from_string("([<:10])")
B = IntervalSet.from_string("([<:20])")
assert A <= B and A < B
### Equality
A = IntervalSet.from_string("([1:4])")
B = IntervalSet.from_string("([3:6])")
lhs = A ^ B
rhs = (A | B) - (A & B)
assert lhs == rhs
### Serialization/deserialization
s = "([4:5],10,15,20,[22:25],[28:29])"
iv_set = IntervalSet.from_string(s)
assert iv_set.to_string() == s
## Performance notes
- Operations are linear in the number of stored runs (`r`), not in the number of elements.
- Union/intersection/difference/symmetric-difference: O(A.r + B.r)
- Membership test: O(log r) via binary search on starts.
- Memory scales with the number of runs, not elements.
## License
MIT. See LICENSE
## Changelog
See CHANGELOG.md. Current release: 0.1.0
Raw data
{
"_id": null,
"home_page": null,
"name": "drange",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "coalesced, discrete, infinite, integers, interval, ranges, set",
"author": null,
"author_email": "Wesley Oates <wesley.oates@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/93/e2/9deaa1712d2d18ba60b86c6ec49e3072f4865bea0045dbc4894114cda3c6/drange-0.1.0.tar.gz",
"platform": null,
"description": "# drange\n\nDiscrete interval algebra on **integers** (with +/- infinity), stored as coalesced runs.\n\n- Fast set-like operations over huge or infinite sets of integers.\n- Canonical internal form: sorted, disjoint, adjacency-merged **closed** intervals.\n- Human-readable serialization with simple round-trips.\n- Hashable, fully typed, and tested.\n\n> Examples:\n([1:3],[7:9]) # {1,2,3,7,8,9}\n() # empty\n([<:>]) # universal\n([<:5],[7:12]) # negative infinity to 5, plus 7 through 12\n([-10:>]) # all naturals from -10 to positive infinity\n(4,5,10,20,[22:25]) # singletons amid runs. Note 4 and 5\n([4:5],10,20,[22:25]) # [4:5] would also be valid\n---\n\n## Install\n\n```bash\npip install drange\n\n## How-tos\n\n### Import\nfrom drange.interval_set import IntervalSet\n\n### Build from disparate sources:\nA = IntervalSet.from_items([1,2,2,3,10,11,12]) # -> ([1:3],[10:12])\nB = IntervalSet.from_string(\"([<:0],[100:>])\")\n\n### Merge adjacent and overlapping ranges:\nA = IntervalSet.from_string(\"([1:3],[4:6])\")\nassert A.to_string() == \"([1:6])\"\n\n### Compute complement within a finite window\nS = IntervalSet.from_string(\"([2:5],[9:10])\")\nneg = ~S # -> ([<:1],[6:8],[11:>])\nlist_not_S = list(neg.iter_values(0,12)) # -> [0,1,6,7,8,11,12]\nS_not = IntervalSet.from_items(list_not_s) # -> (0,1,[6:8],11,12)\n\n### Subset checks (allowing infinities)\nA = IntervalSet.from_string(\"([<:10])\")\nB = IntervalSet.from_string(\"([<:20])\")\nassert A <= B and A < B\n\n### Equality\nA = IntervalSet.from_string(\"([1:4])\")\nB = IntervalSet.from_string(\"([3:6])\")\nlhs = A ^ B\nrhs = (A | B) - (A & B)\nassert lhs == rhs\n\n### Serialization/deserialization\ns = \"([4:5],10,15,20,[22:25],[28:29])\"\niv_set = IntervalSet.from_string(s)\nassert iv_set.to_string() == s\n\n\n## Performance notes\n- Operations are linear in the number of stored runs (`r`), not in the number of elements.\n- Union/intersection/difference/symmetric-difference: O(A.r + B.r)\n- Membership test: O(log r) via binary search on starts.\n- Memory scales with the number of runs, not elements.\n\n## License\nMIT. See LICENSE\n\n## Changelog\nSee CHANGELOG.md. Current release: 0.1.0\n",
"bugtrack_url": null,
"license": "MIT License\n \n Copyright (c) 2025 YOUR NAME\n \n Permission is hereby granted, free of charge, to any person obtaining a copy\n of this software and associated documentation files (the \"Software\"), to deal\n in the Software without restriction, including without limitation the rights\n to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n copies of the Software, and to permit persons to do so, subject to the\n following conditions:\n \n The above copyright notice and this permission notice shall be included in all\n copies or substantial portions of the Software.\n \n THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n SOFTWARE.",
"summary": "Discrete interval storage and algebra on integers (allowing for positive and negative infinity), stored as coalesced intervals.",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/yourname/drange",
"Issues": "https://github.com/yourname/drange/issues"
},
"split_keywords": [
"coalesced",
" discrete",
" infinite",
" integers",
" interval",
" ranges",
" set"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "66c7bd070df23400189542db831ba0629d475a6fb7489a0f6ddd8183bfeda096",
"md5": "0c9c3ed8b72807dd0248758ca1e7c627",
"sha256": "e7995378238714632747ab3e1e27368f7ecfa90bd9f35126b1ad820a405ecb1e"
},
"downloads": -1,
"filename": "drange-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0c9c3ed8b72807dd0248758ca1e7c627",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 10766,
"upload_time": "2025-09-01T17:21:42",
"upload_time_iso_8601": "2025-09-01T17:21:42.019879Z",
"url": "https://files.pythonhosted.org/packages/66/c7/bd070df23400189542db831ba0629d475a6fb7489a0f6ddd8183bfeda096/drange-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "93e29deaa1712d2d18ba60b86c6ec49e3072f4865bea0045dbc4894114cda3c6",
"md5": "02c546aeef2b3d3f7d6f77cfa3f43723",
"sha256": "bf5ed0b0fa48b019eb3ed15423c3717085f201e3f67dec0674164b94c04105b3"
},
"downloads": -1,
"filename": "drange-0.1.0.tar.gz",
"has_sig": false,
"md5_digest": "02c546aeef2b3d3f7d6f77cfa3f43723",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 15029,
"upload_time": "2025-09-01T17:21:43",
"upload_time_iso_8601": "2025-09-01T17:21:43.061606Z",
"url": "https://files.pythonhosted.org/packages/93/e2/9deaa1712d2d18ba60b86c6ec49e3072f4865bea0045dbc4894114cda3c6/drange-0.1.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-09-01 17:21:43",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yourname",
"github_project": "drange",
"github_not_found": true,
"lcname": "drange"
}