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.3.8-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a5f6d40d2da955159d0d934619eb63afcf31910e8caa8313acad4f8a4bb69c1 |
|
MD5 | 68be1c4633a9a198f839ea17ec271b4a |
|
BLAKE2b-256 | bf2d243cc686f84d97c6562f8441c19aeb85de747e0f8fa025bfbec1cd4e5412 |
Hashes for quicksectx-0.3.8-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a8e420214ef4204d1402a4e31f38966a64d07bd1cbcff98a920ead1e2b7cd51 |
|
MD5 | f5a8bce708dedd0a8cff6f1c2f9e642c |
|
BLAKE2b-256 | 174ce86a6f9d5dd52fcf9781a77eab8ab5f10ded7bec2e23cb5587cd4020c5fc |
Hashes for quicksectx-0.3.8-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a3938863b122a6ff6b4e1b88cc031e37bf0fb84beebbec11c9b12ef4c6ae536d |
|
MD5 | 4818d09a48f72b6b53b004cb3e570e79 |
|
BLAKE2b-256 | 140d3d4bdc899dabdcea9b288af01e3041fb3db55539ac2bfa23a3ff9d26687c |
Hashes for quicksectx-0.3.8-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5810d7202934b2107d0cfed07589cd9a36b3a5968dd7eff1cd65e6dc687296db |
|
MD5 | f28f554df76c0e6385af740051991cbd |
|
BLAKE2b-256 | 8733a2ce015cc6170402c3ff41763bbab1c4c31a6cc151e0835f521372663b2d |
Hashes for quicksectx-0.3.8-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 934da3c8d1326cd05f3ac21c883a6bd7399122bc6ccd0908bae9e04b80ce8508 |
|
MD5 | e86dab1a9f2c715b4308cf74b0d3255b |
|
BLAKE2b-256 | 7f58c6a0ce721428dcb1d19f723fdd0fce854bce5b9ab3a49210035e5bb427c7 |
Hashes for quicksectx-0.3.8-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 39fc2397f355d18509731f9ad154e719594dd55e65759a37ca6a4312a840c4d8 |
|
MD5 | cdc015532874c2ee34426c95802c2f1b |
|
BLAKE2b-256 | a72a2dd7bbdce9f636b30fa88e841ad378299f84a3993063e96f8148bf80edc3 |
Hashes for quicksectx-0.3.8-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e712eba88370c10e28be50b0480ae9a2b8f5de72844129862ea0595e6929ec0 |
|
MD5 | 17d4ba13a6047b993a800bd1167cb964 |
|
BLAKE2b-256 | 03eb22699ca1d2146f9349f99a4bd1d1275a8f272aaa929e6eba5036254257cd |
Hashes for quicksectx-0.3.8-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b46af37d60ac2a0c598e068243e89d9b97765333abcaee309e8f06fb573b1574 |
|
MD5 | dae0cc0aef9d715e3995b5ef889c14ee |
|
BLAKE2b-256 | a676e7f4d2a1be8358dd70414f9ed438dda2dc4c2e0d3ac812eeca5e3288e49e |
Hashes for quicksectx-0.3.8-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b6fed2b256aa3580015c343bfb694c36043c588a2600afe19365b79e7f1af55 |
|
MD5 | 5a2c50bf25886251c45b1a77c915e8ed |
|
BLAKE2b-256 | 70583390803b7ab5ce9fc3369af5cebf442e271b29f5c0bec78e499c4ff81434 |
Hashes for quicksectx-0.3.8-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92bfb428cbc44939f04cf9698380f511b03fca55e8dd8d161e0313784eff95b6 |
|
MD5 | c33bca540e1ed178d0413b602390e17a |
|
BLAKE2b-256 | 85ea78720cd73f33607c2ffc67feb53c9999c481a98474e440bae829c4788d50 |
Hashes for quicksectx-0.3.8-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d1f55a207eb4a06cd01e21e05ee9b37dc893dea16102b635ef6b39e1421bc9f5 |
|
MD5 | cd67035f531e760c7858e8d6a294f17e |
|
BLAKE2b-256 | 7315a59dc61d04cf2192cf3bb4ae8701782cfb40221cf3286b2555452473160b |
Hashes for quicksectx-0.3.8-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12bddc88fefa04ac6777c23b299f86b5eeeea903dee4479d734467880038c308 |
|
MD5 | 019324eff5c4070d949531a672978341 |
|
BLAKE2b-256 | f09c5e31b58696b0778c82918d09eb5c8eba49f4d20f754da707869ef9f5f322 |
Hashes for quicksectx-0.3.8-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4639e226d173174074f186297719461f09c5c15c9909688d5b78dfb0a3db00a7 |
|
MD5 | 92aba9a27bd4ce1fa4036af70de93348 |
|
BLAKE2b-256 | 18e4084640288cc6507e2ad5a97ac9977987737e97faa5fffe10aafbd08ad8e9 |
Hashes for quicksectx-0.3.8-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ebc82918371ce7fc6d1ae888b0202ba09a0950e7f0d438f1fec14c0892ed373 |
|
MD5 | af71bf1fecb62f3798166b3284e8dc77 |
|
BLAKE2b-256 | 3b8b5b9477283a2d112f3f176548f0fdb6c1167beb4d212c3c8a5d9ad8117013 |
Hashes for quicksectx-0.3.8-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92397b7141eaf01a30b43b56e44d9f46aaa20cacbec63159aea19d3ede71e8a6 |
|
MD5 | 8544aec623272a716ea1e1ad31aff687 |
|
BLAKE2b-256 | 4fe5058fcbdaa49742a041276fde638047d632dab8e9043df589a42b99dbfa86 |
Hashes for quicksectx-0.3.8-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 02d51a25ca2c812426da009e4ac87e2b1349ff615a0e36e658ee4c605fea01d7 |
|
MD5 | fbcc918220eb55d69f519ad7f11771c7 |
|
BLAKE2b-256 | dd760e454319be2132a5b5dea7bf9dfce6f030f8a568d206bf5a588ab76b117c |
Hashes for quicksectx-0.3.8-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3b9116c626cff95796b962f1448f1518f6d470931cf3a0c40cab4d71ade2bc7 |
|
MD5 | dd68677df42b7e503aba6245db39fc8d |
|
BLAKE2b-256 | 764d09159521721d979d402c17b821d84ac5fd5e5ab35a2415c33ccd802797d9 |
Hashes for quicksectx-0.3.8-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d9d9c0e3aedf7e9bcef0b463c6a6983e46b8626a083c2f66590da24aa90e04c |
|
MD5 | 43656efad9d567271c33cd5e9b4e9092 |
|
BLAKE2b-256 | b455eb5fdc359527eeddd3158350ccf45a52fbcebd8043b2f40d9717c80f6106 |
Hashes for quicksectx-0.3.8-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1506c4c712a6dc306df2c7c74bcbda8f7ca033cf0df62845e88e0eaf08447b4 |
|
MD5 | a749c831170bd8da51f38fa39ea647f9 |
|
BLAKE2b-256 | 9d4119d9a0804398e7602310c626d1c2f84ed31b58ab5ae3bbb7dd802c733862 |
Hashes for quicksectx-0.3.8-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c10afbc35a9ba337490a72c23c4b31a074b6db1eae0f5111a410d30a7e3d46da |
|
MD5 | 33195cf8d3e5b700c84bbcfcae20963e |
|
BLAKE2b-256 | a65301d8e220ded4e07544908606cc95cecba5571400948d90ae0ce25291deb1 |