fast, simple interval intersection
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)]
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.3.4-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e5917653ab3100285708ef461b84b1aee0c959c8470d09cfdc5124ca840ec46e |
|
MD5 | 337cf66fef3a4ccdee1bfdb7a73570a1 |
|
BLAKE2b-256 | 90cdfe3f0dbd20f04b57fee571b8dbcc6a1bcd295f27b4562cb9cdb62f9c4fbe |
Hashes for quicksectx-0.3.4-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06fb45867b7de2e92a2bd3fb774fe9b5a3157502464b8fdcd0ee0f49986233eb |
|
MD5 | 08f52795d3bd508f4610e86ce6e5b28c |
|
BLAKE2b-256 | 44133ac96d3a9d513daa45f313b150be6fcb915a827ee803feeed5222d164ab8 |
Hashes for quicksectx-0.3.4-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a73297fd1ca7f912faeebb06b5f85bdfff5c770792df193350f4952034a4e49e |
|
MD5 | 1f6d7eb63f20f415a249fab8701be35d |
|
BLAKE2b-256 | 49db6c6c3bf415d31bf79006886acc179c6fb3c8a178eb310cc436ffdbb7d488 |
Hashes for quicksectx-0.3.4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9fc37bb1359ef5e1659e9709a18579aff18099183acc6a999054cbc38bca732 |
|
MD5 | f052c45092ebd6c448076cb685fe97a4 |
|
BLAKE2b-256 | 76d26472db52dd3fde11e9ff5d5e09aff9fa4e40922ab235d2907d6e2f3fa064 |
Hashes for quicksectx-0.3.4-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 25a3adc50ca424b1b2ba0c2df17c55700c3a7e0aaa0453376887ad8458ead58f |
|
MD5 | 50a3baffcb8c6850015b515ed02dae1a |
|
BLAKE2b-256 | b0e0e29bb79583a3ffdc0550ef5bf415ec1fd6b6c3b9a7588225211baa581bec |
Hashes for quicksectx-0.3.4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6bb32ee08e271061fcdf0c47072c6793ae9b1771d54946959c4a55bdbbcabea2 |
|
MD5 | 3805679f586553cadae53ad1cf49abfa |
|
BLAKE2b-256 | 387bb3f63bba45a24e340afeb72b5eedbbe6b1d9afa75a0ced9138fc31f1c87c |
Hashes for quicksectx-0.3.4-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa8b14840eb88a726bc443784c07d2d19df22a075acb546c6f50a418427ef338 |
|
MD5 | fb8320d93118321b013636c0181a7db1 |
|
BLAKE2b-256 | 60f6e288ff8182462abe9c234450f195103a3f2f161debb3f6d2b08cd518151e |
Hashes for quicksectx-0.3.4-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb57584b6c51cb08cea5fa209ee39ae6ab53109fa0e493a47d8dfb47ecd8535d |
|
MD5 | b375da3e58115fffc824af5160ae116d |
|
BLAKE2b-256 | 553980050a4ec405313d5f1cd5661d70f4b1fdaca219b101d5f5c8e009c6b5b4 |
Hashes for quicksectx-0.3.4-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 67ff6db00afba649c5e0fdc07ed86857bac3ea9526ecf012463e3b8efb9ec5e5 |
|
MD5 | d92e14398ca6991ebfeec5ec5a342c5d |
|
BLAKE2b-256 | eafa85f58319be605430e167cf19b3ed28f5b2f1572dec3e544dcadd9aaffcd4 |
Hashes for quicksectx-0.3.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 573a164a78049c63d9048ebeddf9c0bdc96897cc634a487deef4a708b5b39023 |
|
MD5 | 1f95282349be8d54bd0658a4ab3306cd |
|
BLAKE2b-256 | 5388a0f7d851ec373067014db12c8929507cb23e60cce9d652cda8ee012c4ea4 |
Hashes for quicksectx-0.3.4-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ae0c9d34f7900a38aaf574f22423033f9c25fbebe68e44c939a74cee5182c9a |
|
MD5 | 07a1845fff18f07c1378870e64c05a65 |
|
BLAKE2b-256 | 03d5adb3e3458b5572bf70f20fa35f899460d1e442c735aa0df9935640cf29fc |
Hashes for quicksectx-0.3.4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4c83706721aa20c2c4fdef801cbb8333bf1845accc5b668dbc98c568bd40818 |
|
MD5 | 3356040c00a4d8c1be076907db1a3a01 |
|
BLAKE2b-256 | bf3959a39e3496be6a123e89898108e4bc97b3bf56aeef4e7664a9a3da7e06ca |
Hashes for quicksectx-0.3.4-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f96ad6dd4bb11a3de12dbb060cdea4064d53b2d6f548e9a4c921c1b04c33f96a |
|
MD5 | 1fbe7935535e89c55600977eec910d70 |
|
BLAKE2b-256 | 5372ac847defb2dddb49261eb847a3025b866d4ba021dc0164484fbddaa1142f |
Hashes for quicksectx-0.3.4-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3343b35213240d4f64bde728c6feb3834deca79c379a91718dedf803627bdd5c |
|
MD5 | f6e634548b6dfd30a20c7b06c25882d2 |
|
BLAKE2b-256 | 1512204d6bf7e501e9c9b63e8b7cc4b716bcf1981a0fa6d78d49fac1833c87b6 |
Hashes for quicksectx-0.3.4-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08e2d1b4ab41e9cdaa585fffb2d747c0da32127cf937e1385633e7b5839ec125 |
|
MD5 | 19e1c5d3ebf680d63b676d27a612059a |
|
BLAKE2b-256 | cdb5b68ed9b6d159f14a278fd33e348bbccb3ec25af594e78e67da4cd7133d36 |
Hashes for quicksectx-0.3.4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9e647bd4bc77968bd5c3c530fce7f87a0c87457a69fffe81f3c4abd66221870 |
|
MD5 | a04e9cb16dd2fd5dbf1800daa7100c3c |
|
BLAKE2b-256 | 438e2af910c20d4809b3f6f3e01b860e098e8e367c6a49fef6e75b6b5ca209fc |
Hashes for quicksectx-0.3.4-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6cf7d84b86192d9de2ec9f18ffec82108f3a1a3d07bc3bd0036760e812ebb1fd |
|
MD5 | 396cce89a909d862208dcd17afc1b9d9 |
|
BLAKE2b-256 | 7c6e7f2aa6e1fd70fc5d4ac43ae20234412dd0e55796ba5b58d5b071d7e1fb69 |
Hashes for quicksectx-0.3.4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3280405a8d981244a3d60fca9757ee82fe0b2925ff4bb2ff9cafbd97a9d885ae |
|
MD5 | 2cdfbd35779dc28b50bab7189f50c67f |
|
BLAKE2b-256 | ba17837540519bd79b904f76929b48ce9cceda429cd7d11cb45d5db6aa590ba2 |
Hashes for quicksectx-0.3.4-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03b775dcf23a0dc148950919091a8d6ed001716d03713168de72d1b151c45e96 |
|
MD5 | 32e4ae690e1c612531746e0d8c6867c4 |
|
BLAKE2b-256 | efd26d89e67df4b3dc8370ee2462179b88078e4576b9d7e20d7947dff9b03c0b |
Hashes for quicksectx-0.3.4-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5b92b08ace9fe419d6ba9838221dcf7b9a978cd99e5605e534d26bb7616b11c1 |
|
MD5 | 276b3d9da5cf4c7d0aa857d7a888beb1 |
|
BLAKE2b-256 | 369c955c8eb3a863689c6bf09e127a51e1f32f55a51f773956c72becd21b051a |
Hashes for quicksectx-0.3.4-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a229c77dddef3f463b70e3af06a64e90ad7d99e65298ae80c6d3c7e28042ecc0 |
|
MD5 | f635d0fd5eac36be267770b40b1295f9 |
|
BLAKE2b-256 | 9415ed1cce45767c9df90b5df23cd1b273572c317cbbe7d73be6679a947b5eef |
Hashes for quicksectx-0.3.4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 848b9a2b55685e1e362e8e162df60a7b20fbe0fed9183c776567c84400a768b6 |
|
MD5 | 9adcf7ef58627964d942efbad3208794 |
|
BLAKE2b-256 | 5897576666839e0160efb460be840113d2b68dfd0322a3974a952997755b2ad7 |
Hashes for quicksectx-0.3.4-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4dce946d518c54cb932073038961a22dd49dcaa53eda7c7979adf3beccf7d2e |
|
MD5 | 73a4fe85e9476d76dc69f95502cacbc4 |
|
BLAKE2b-256 | 74f310babb8a9234cb1b3e57b3e89cc03611691903be9c600fe874c1db076ca3 |
Hashes for quicksectx-0.3.4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e15d30c26b93419dbd33be4186fec188bae7339bbd6ec34014443deeca64f557 |
|
MD5 | 095e1fbac92fc0750a911926e6cd9d6b |
|
BLAKE2b-256 | 97c4d30e041709a83867bb413311acee413811d23e07d3802d80428b47c87ab1 |
Hashes for quicksectx-0.3.4-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d5f2254bb9a42b4a71c5327ed8c47b914bd12e58af58932ef15bc20470bd9264 |
|
MD5 | 41b1f4035c59e523d052d253cb14d3ab |
|
BLAKE2b-256 | cce68fe944307af9e9bb1eed4abbd2ea90548e31224890e907c9edbf6077573a |
Hashes for quicksectx-0.3.4-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6610941db4b819f6580f94abb758366aefaacbdaa5d60d40d039456277cf5119 |
|
MD5 | edad6977def5f5d05e2129c4006dd14f |
|
BLAKE2b-256 | 16dc07bcbd3224e960bdfc0f5d937d1b9e809c72dbd4e9fc75b7cd50f1d60f75 |
Hashes for quicksectx-0.3.4-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2389d726f172d81a0b9f77a20ac726e90e564a7a3f4811190a145a4f1a1a18e7 |
|
MD5 | 401766fd788f528ef7abfbeac4b2f511 |
|
BLAKE2b-256 | 04934a5ae360bcc4630b1996ce91fc430724216dd206daea6ec082114427c34c |
Hashes for quicksectx-0.3.4-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c7fe3efc38e9b59966d6778395cc6f465a392d4294cb080b852894f67f4436d |
|
MD5 | b82e4aa871168e78d6b37d3a972b841e |
|
BLAKE2b-256 | b65c44dbb59fd6d550615614919fd60aa2f3e490233d48505007d9c04119ec9d |
Hashes for quicksectx-0.3.4-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ac35fdbe683e46cc5053a9f13f828b3ce9bd0388b90231d807b96c4db90e6c2 |
|
MD5 | 5dc1e0430712faa13801cfd976d07de4 |
|
BLAKE2b-256 | fa09e883d3a39093eb64906c25e37b7568be47e1489f55d755be729640c8f0bb |
Hashes for quicksectx-0.3.4-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8af051e5ebfb97c8b4e75ec4298e2655ff2977ee0bd6b190af4ca4d2cbef9d82 |
|
MD5 | 4a60c26e2aebda1441390846c20ee961 |
|
BLAKE2b-256 | c8d7b8094e24c263cb43e75400ef663e15594e948e52b9f9507e217428855d72 |
Hashes for quicksectx-0.3.4-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7859d3eeee11142ce0982f4a76bd876f9ff9b4655a4796063eff76d19c2602ce |
|
MD5 | 403245450a2ec5e56c99ab0e6b6522cc |
|
BLAKE2b-256 | 2d67ee8b3dadd318b5116c50f08f694b0807f6ea07bfca071190f665eb4e0dea |
Hashes for quicksectx-0.3.4-cp36-cp36m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1fb60f14200f3849354a43f776ca5263ba969570a7d6edc7a8d9aaacddcda3f |
|
MD5 | 6930d1e42f1f48f1b4b572a5ef2b345a |
|
BLAKE2b-256 | 3518eaf38bf7fb6b7147d3f708e47505c7bc1cf70ebc6d9cf2e4643fde514e2a |
Hashes for quicksectx-0.3.4-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdfe74c1dc38149da6a70caf5dd7c90679cdcc491a9852fcc7fd04fc58a6134b |
|
MD5 | 0653320f4fbbf918f3bd9cccf9adb899 |
|
BLAKE2b-256 | 267b283b1b3843490a871736ce728b9e67e45445e0de178e946078fbb4ada853 |
Hashes for quicksectx-0.3.4-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0926d19d49bdf6f8aa5ec2a462f4297c50b419baaca9a24dec5065d004c479ca |
|
MD5 | bef2a3e094bc6e3d9fea8da47bb1e02e |
|
BLAKE2b-256 | c70878393e0a4558d92d3b542b480b50f114d09acc7eb1fdc3ad0e1eddf83096 |