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)]
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 Distributions
Built Distributions
Hashes for quicksectx-0.3.6a0-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71872776233a8e548afba9f392ffff436fd6f110f9c71afd091e77c1b0d2d04f |
|
MD5 | 41feb5c7e983781885af45d71c8c3762 |
|
BLAKE2b-256 | ed8e4c4def727255f5694d0bb973a6d2f66f265d6132c32de938e62130e30562 |
Hashes for quicksectx-0.3.6a0-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 86496c7af94d71bb8184dab83d8defd9131e258ff27b5a4440037d2aea5a1e1e |
|
MD5 | e65607fa79f1ace0ac78bb1c74f1dbaf |
|
BLAKE2b-256 | 66b5ba651b41a9b5ac34dccbc0e5e39d7f50db37713cbc3c2c2425d24629566e |
Hashes for quicksectx-0.3.6a0-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4af14205733e5f52c77c076727093978cc6156751c1bf8a1c91f985815af66ed |
|
MD5 | a94ffb58873f823370ed544bd36e4487 |
|
BLAKE2b-256 | c80e1017453f8ae52b50a418c8ecb2b5fe43cd2bea37b6aa885be4113b1a4be6 |
Hashes for quicksectx-0.3.6a0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4feb793c9158d0cf8394ff34aa0e08fdfe8b69049cd78c5fadf101c92aa684fd |
|
MD5 | b18742f36013623613521f2682f27c68 |
|
BLAKE2b-256 | 88b9fefbbc9c13f1b0b44ab6aa19034b22b09cef7fc619e41f3a40258d81e1fe |
Hashes for quicksectx-0.3.6a0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a52f3ef2b9a5f4dc68428cf9f58297d9072f735d5c419a75770b2dfab365fcb4 |
|
MD5 | 2c4338f760586f55f4cec5ae27294ce0 |
|
BLAKE2b-256 | 2e5e5d89a926fc7a9989e48bb016a8f55005971fb339e697fbe30f02f1c5225a |
Hashes for quicksectx-0.3.6a0-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c539f5909b8262c3c117de1c56fb72027ce9ca5e160968602708ff44186427d |
|
MD5 | 2bce55dfef949fdd17c597ca8da03b9c |
|
BLAKE2b-256 | 03d982c18ff70ab3723e8813ee951140e5cd73d809910b8d6a698457b955953e |
Hashes for quicksectx-0.3.6a0-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a572201aa943c93b65dd60b47908c528f74fb03ea30191706b1756f0fb922b26 |
|
MD5 | 80e48d26bb7ab6934ca4bf13ebfb1d7f |
|
BLAKE2b-256 | da56d2a48e37990acdc9b69baaf45771a6679aa55902cc091d5afb33f54c8ef6 |
Hashes for quicksectx-0.3.6a0-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02f273e7527fa3f4cd7d279b355c597e013c372d979a6c5115fc89e3b31efb3e |
|
MD5 | b1e164c3f3107a523cd4544253ffac54 |
|
BLAKE2b-256 | 310cf6b30a4379cbb1f86a23a72efeac8623cdf55d4f3dbff4e157a24f47e100 |
Hashes for quicksectx-0.3.6a0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4023da5c31708836d5eebbb1f00746ac30181ced49210d7cc4a1fd2986004422 |
|
MD5 | 3910574ac23d522f17216ca6181398bc |
|
BLAKE2b-256 | 28006e3591a48a9122190515903461225faf9ca38522a42325c366224e4ddc72 |
Hashes for quicksectx-0.3.6a0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c4e880d20bffc1a67148073600a3a685f6678f513f63052c97dd799a34ae8e7 |
|
MD5 | d830c4b649f24c7c476c1c7ec55884af |
|
BLAKE2b-256 | 9cfc2eb67ce101f5e0dc957774a242609aedcd227c97b40516b138454296a7eb |
Hashes for quicksectx-0.3.6a0-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e64eb6ae013016fb75d4943485baa7257205887ca7e513f3db50c538abdf6d4c |
|
MD5 | a7836693b15dfde1343ae1952aee5738 |
|
BLAKE2b-256 | d786c0e3ebadfdc0b347988ce920c78ee5edb5a9aec7778b0afb65f7484aae70 |
Hashes for quicksectx-0.3.6a0-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3581f243cb0f24634c9a884d6eb243381a18bedbb5900b8ae0c266074b278b2 |
|
MD5 | 4a7a1d087ba3e9c50b3268f9322611cb |
|
BLAKE2b-256 | d54edad09bc3effa1176b13997d5c17464b056c09056659be519ed352219260d |
Hashes for quicksectx-0.3.6a0-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c5301705cb5d7ea66a7d0e506a68f97395b18db3d49d1da12f16750e3f79226 |
|
MD5 | beb1ae9f0b708abf3b2d2dc568ce32e3 |
|
BLAKE2b-256 | f5f76d8a514e7d1abdb14f3b883fdf7d3f62b9c032036e34bb6f14d6d1ce85a8 |
Hashes for quicksectx-0.3.6a0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be700d53926121ae01aba648ad0915e16dcd87a6b050daf7ebed0acd4ebf9c3d |
|
MD5 | 4298d406791ba481075f25a7fa0ea27a |
|
BLAKE2b-256 | 6dba2c4bd9f467a659322abb4dddda622526cc097afaa596ac2e53753533ebb6 |
Hashes for quicksectx-0.3.6a0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc3c8cd3cd12fd5a3d20166dbd76d4206918a16fed960f2a94529974976e9ca1 |
|
MD5 | 5e21bd0cfd3856982ea97062c122e704 |
|
BLAKE2b-256 | ad65e20f31e8c858e620d1fff1a34f6c3d60f8cae2ec96029385ebd8313951a3 |
Hashes for quicksectx-0.3.6a0-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 951cfb34b996fe323a12935dc1046af22ca6dd347208338f328f945b937d93f1 |
|
MD5 | dc90d747de5df6af071c6a0cacad7df6 |
|
BLAKE2b-256 | d07950b0a543c50cb5f0b3c77e470faff52527a922ab56f71e06da21cd43f6e5 |
Hashes for quicksectx-0.3.6a0-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aded4249b184fb092322d53777bbd8537939c260812d2620f77632b8e0e3e377 |
|
MD5 | 37244892af5bc439ee4e9189b200b0e2 |
|
BLAKE2b-256 | 446b49f3e885474152a43ffaad28fb4e9b43f552c96d9a8ac9b956a4adb8d301 |
Hashes for quicksectx-0.3.6a0-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97af4626c39ffa7be6cd5b439eff17999839f9792983adf67459371d849804f5 |
|
MD5 | 80446f722b1577436aed03edf91a6879 |
|
BLAKE2b-256 | ce8300b6e015be3c02912b3cd5ab0d20f9e486377ad2df77180f35253ea4b2f0 |
Hashes for quicksectx-0.3.6a0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ae5c65f66b4da746655112b84f5297483075e9839104dba8937400c1c5938cb |
|
MD5 | 5132b817a3ffeaa8d81960b50a71f4a6 |
|
BLAKE2b-256 | 3625fa782b8a82c2f0dc68351d4998a9d6a59a013e208fa5acd3c7abdcced4b0 |
Hashes for quicksectx-0.3.6a0-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab6bb12331eb7555465f8f933bc3009e802e7b7fdc14d3e6e1a976786399f1a3 |
|
MD5 | 6ae29579dfe4df59aad29a22f0bd702e |
|
BLAKE2b-256 | e572e6021bfaf67af7e047ee0f3cc52d9042a0e90630452b323406ffa19fe345 |