Quicksect is a fast python / cython implementation of interval search.
Project description
Description
Quicksect is a fast python / cython implementation of interval search based on the pure python version in bx-python I pulled it out, optimized and converted to cython and James Taylor has incoporated it back into bx-python with his improvements.
I have brought this project back from the dead because I want a fast, simple, no-dependencies Interval tree.
(https://github.com/brentp/quicksect)
Extended with removal operations and allows pretty print to display tree structure (By Jianlin)
License is MIT.
Installation
pip install quicksectx
Use
To use extended quicksect(quicksectx):
>>> from quicksectx import IntervalNode, IntervalTree, Interval >>> tree = IntervalTree() >>> tree.add(1, 3, 100) >>> tree.add(3, 7, 110) >>> tree.add(2, 5, 120) >>> tree.add(4, 6, 130) >>> print(tree.pretty_print()) Inv(1, 3, d=100) r: Inv(3, 7, d=110) l: Inv(2, 5, d=120) r: Inv(4, 6, d=130) >>> print(tree.find(Interval(2, 5))) [Inv(1, 3, d=100), Inv(3, 7, d=110), Inv(2, 5, d=120), Inv(4, 6, d=130)] >>> tree.remove(Interval(2, 5)) >>> print(tree.find(Interval(2, 5))) [Inv(1, 3, d=100), Inv(3, 7, d=110), Inv(4, 6, d=130)]
To use traditional quicksect, you can still using the same syntax:
>>> from quicksect import IntervalNode, Interval, IntervalTree
Most common use will be via IntervalTree:
>>> tree = IntervalTree() >>> tree.add(23, 45) >>> tree.add(55, 66) >>> tree.search(46, 47) [] >>> tree.search(44, 56) [Interval(55, 66), Interval(23, 45)]>>> tree.insert(Interval(88, 444, 'a')) >>> res = tree.find(Interval(99, 100, 'b')) >>> res [Interval(88, 444)] >>> res[0].start, res[0].end, res[0].data (88, 444, 'a')
Thats pretty much everything you need to know about the tree.
Test
$ python setup.py test
Low-Level
In some cases, users may want to utilize the lower-level interface that accesses the nodes of the tree:
>>> inter = IntervalNode(Interval(22, 33)) >>> inter = inter.insert(Interval(44, 55)) >>> inter.intersect(24, 26) [Interval(22, 33)]>>> inter.left(Interval(34, 35), n=1) [Interval(22, 33)]>>> inter.right(Interval(34, 35), n=1) [Interval(44, 55)]
Since 0.3.7, you can use python’s native pickle to pickle an IntervalTree object. For details, check test_serialization.py
For Dev
Now the version specification has been integrated with setup.py and pyproject.toml. To update versions, only need to change the __version__ in quicksectx/__init__.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for quicksectx-0.4.0.dev0-cp312-cp312-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4fd636e9af9c7c580d609322e5618bfe81727fe2655579cd6c5bfe2e280ebc61 |
|
MD5 | 31fbfb0674d3e6b8215acd0c937ce2b2 |
|
BLAKE2b-256 | ef7d9fd397c71ffc5246839b13102ed3ecaabec6d02a2bbeaf99716ef4c1a069 |
Hashes for quicksectx-0.4.0.dev0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf33a9bab089aab028472b3ca6e9ef1c9f625e8d2db57bd70140b4327a2ddfac |
|
MD5 | 5de0079efb33e1f513c6de33b4266dd9 |
|
BLAKE2b-256 | f1c2bfa802188a64e19e3244e8cbb19d022c80bb0ada85f86c617ae81663f65a |
Hashes for quicksectx-0.4.0.dev0-cp312-cp312-macosx_10_13_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5dd5f93b946b4294339fca9743a3e0a61e5de9546bcfa34a89cb52f16e71abce |
|
MD5 | e57ae063aa7a13dc82e0d8fbf031f3b6 |
|
BLAKE2b-256 | 6f95fa011eb2b7aece456126825629e35a7fcaa51a6595c09ffd0fb32b941357 |
Hashes for quicksectx-0.4.0.dev0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 803ba3ac0ecf524cf5a4d3b5e103338fc34c66982e6b22c411bc36f753c3da5c |
|
MD5 | 3f0863f48c2fec86558040d44113d217 |
|
BLAKE2b-256 | c9798f2231a36f6d582293db4cfcd6bb9f63aca14202daec6cccf0c596a7ef11 |
Hashes for quicksectx-0.4.0.dev0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a837450fe8f7b2c45ecb336263bbdef203c724dd91cf87d3792c64bedd348f20 |
|
MD5 | 766773e5cfcae9cbfca506456c250545 |
|
BLAKE2b-256 | 09510d2e4a34f105deb95c887f4e296e04afb0cff38cf0f5ec9549100e29fc32 |
Hashes for quicksectx-0.4.0.dev0-cp311-cp311-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00b302de8cb2c5e590381c33d61064bfce62457eb264c1d638009c5356203466 |
|
MD5 | 036c2dd5754c2cd37da38b19f0e07f7d |
|
BLAKE2b-256 | 5736104246b00c8d0248e69281ccc41d81daf747f130ca476efe0d30fe5ee73b |
Hashes for quicksectx-0.4.0.dev0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ae0a26fa1620fb324328a4a03ebbc08eb91791ca0a27262808adaaa97b09ddd4 |
|
MD5 | c66dae81c25b8d2937b8788885afa6dc |
|
BLAKE2b-256 | e1d21d96a16f06790a13b9848734e966f0fcf3e37f4a0bcd2aad0c28b9de5f0b |
Hashes for quicksectx-0.4.0.dev0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c7eb57c89afe79fd2ebbd1adf0fe462a231dad7fa26f56d401646ef6c8a0e54 |
|
MD5 | 849e2d1442e3c7d9cdd81a0eb8ca465d |
|
BLAKE2b-256 | 5e6e3551e5d4c1180e8e1245c534da0220c3a20b6a1977951ebe7a4cdd2b3f93 |
Hashes for quicksectx-0.4.0.dev0-cp310-cp310-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab3d1bbc6e254e15c8ec08f331b99d88f878a2e648e1171913279d9c99ae8e11 |
|
MD5 | cb0e208fd329b7fad8483c6b7a8f4f21 |
|
BLAKE2b-256 | c08ba793c91cd3148d832f4f8eb503228a2a9b923edd39e2b26ef37a48502bde |
Hashes for quicksectx-0.4.0.dev0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 94aca51a90adbfb1fc834faf8f1d2329c56628516729ff8a19fb44a186321e76 |
|
MD5 | 68955ef2d47dc682ffed452d9cd3a26d |
|
BLAKE2b-256 | 2857b21177f5f3f56c401d212fa4adea19137d8a63104a25cb81c9ce87fd2aff |
Hashes for quicksectx-0.4.0.dev0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e592919568565cf8a87198061bb4e7a9148ef4ca7479cafc0854b80e7a5311ff |
|
MD5 | d210a4c67075a828d4f93b202334346d |
|
BLAKE2b-256 | 00d795234b126859e101574eae6397828fe40385c763c290856c0c7b4db6b90b |
Hashes for quicksectx-0.4.0.dev0-cp39-cp39-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1efbb262297f10fb9c505370cae9b9faa282d5682606aac7f710f76ad8d0b82f |
|
MD5 | 408bc661fc748434e3029b97ae7b6535 |
|
BLAKE2b-256 | 90dbaa34ebd65ad32fbc436cdfa5c8a6e784a9cb36db72a2bed439bad79be6b5 |
Hashes for quicksectx-0.4.0.dev0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | daf773d32a264e23035064234f5eb92d04801a6f6a1d4207bef290c6d06999ae |
|
MD5 | 919b6c1d06d11648e57ee5d6a92d645b |
|
BLAKE2b-256 | 347e9acd83c83889bcf8397828d70d218a1c87fe8ad3f879c5f6ff90fc9df29f |
Hashes for quicksectx-0.4.0.dev0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa4cdd308fccb40a3e4f4c23174f27ddeee56304ed980d3420604b5b259f7a9b |
|
MD5 | 12a337b896674067470b5ab6586c487f |
|
BLAKE2b-256 | be1e27c202a068735ad10bfea6175290d0d59e545f8d9ba91a4744bbcea41d18 |
Hashes for quicksectx-0.4.0.dev0-cp38-cp38-macosx_10_9_universal2.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a27c3b1117106deacd878bc23a06793a990ad1aade20093e19fc25511fb3e112 |
|
MD5 | 28e893eeb592864de3d3dc5c5f494551 |
|
BLAKE2b-256 | 5d3da13bb4e5178e8c79e1b1358c07fd960c328ee1180ff3e27e978683b8ed3f |