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.
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)) >>> res = tree.find(Interval(99, 100)) >>> res [Interval(88, 444)] >>> res[0].start, res[0].end (88, 444)
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.0b5-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8f869f171d3794527dbf0b6534ce978b160f0463fc142167c3eb4502a87916b3 |
|
MD5 | 6423028a9f29e566ec75207ca9aa7092 |
|
BLAKE2b-256 | 4bafde7ce3d1d2241628d9c86dadc9d27e78c5bfbb0336036c0838262480839c |
Hashes for quicksectx-0.3.0b5-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1c15126af7ca29fe31cefcb93660908a273222ad34d4c2907b96c4d4d0705d5f |
|
MD5 | 31f8485b5adcc33ba511a367d6bf2b38 |
|
BLAKE2b-256 | c3a72a779ac9b023a6893cfdef6fcfd0064a31194f4e901ee397c7372dfec84d |
Hashes for quicksectx-0.3.0b5-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 45efbfbaab0b860d7956b9d54071fa74bebc188030cbc2039d496e2f607dc23a |
|
MD5 | c5573823479c8815504e3700839215af |
|
BLAKE2b-256 | 094dbc4bd6771aaeb1dc8f1c1c4492fea0355c87757f85ccab7b29a14de70837 |
Hashes for quicksectx-0.3.0b5-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00009488509656f858434442bb3407db74177acf6df34f37c306aad873372910 |
|
MD5 | cad1624038f7c108c38b12c3acc41267 |
|
BLAKE2b-256 | cc6fd81cb6f7d8e7ad3c28d600f6d4ec950911d6f27dc1504707dc0e3d20be2c |
Hashes for quicksectx-0.3.0b5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 70fc45dc31c55f5e5bc75bfb11ee82e3ec06e96bf6959c24e6e254448027de50 |
|
MD5 | a4d01bd3e2de4941a409774a41214f7f |
|
BLAKE2b-256 | f8fa8e1c80982c442518adc06e2ba19105eb40e1f0636b849b1adf1f9c2b22c4 |
Hashes for quicksectx-0.3.0b5-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92f939e76660e9d5d45c4af697d2f63ebb3b302b579f529ef100a1094ccdfc68 |
|
MD5 | 076968b24b88e12446c88b6ab69c6bc0 |
|
BLAKE2b-256 | 68a3d297a81b505cde679536021cbf29101c6f0a1ceaaf264f53d70603545206 |
Hashes for quicksectx-0.3.0b5-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3cdcf13858f8766e6d5c728cf06ef52fbea64cc894748b9a8887cff2944585b |
|
MD5 | 114cf317856712e3d526ab11b52fbfaf |
|
BLAKE2b-256 | 64eb5039d452e24f2b381080fb4b138ddd994d2ae9e08da349afd0635506f1e5 |
Hashes for quicksectx-0.3.0b5-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ee033bab6d8b9c1a43903a3b5684981f0887f9f48f8cacb9c89902b20b40d0e9 |
|
MD5 | bdad2cec4469f9b92ab5a8e429f22679 |
|
BLAKE2b-256 | 9b1356c77d0ea152ba4bcf4aac3d005a36fbf10277bf1b5f25255491f5e6ae6c |
Hashes for quicksectx-0.3.0b5-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6672a847bcd31a613887e02e0eb82fadeb4c37abfadd66c42f1a1ec35f2cae30 |
|
MD5 | f91ff6969489798f30a8490b6c9147e3 |
|
BLAKE2b-256 | fa94bc5bd7fc3f13c8478244d5297f61fd83b58daaae8a23b940b785738ea5a0 |
Hashes for quicksectx-0.3.0b5-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 15964cf010ab3a3fdcc0864c3730f364b6912dc18e616467873f703ba237972d |
|
MD5 | 7009947b4e6884d0c6be71765994348c |
|
BLAKE2b-256 | 9a2274ca5e9e03d605b2c1ea00dfc0af524beb3c14d59d27ad298f61f503e579 |
Hashes for quicksectx-0.3.0b5-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fcce22decc0a5cfa3de795e2a45a9c813b3daefc44b84658557084f39ebd7b8b |
|
MD5 | 138df086244f1cb9f7b4ed41ef6159bc |
|
BLAKE2b-256 | c49f3008fa1e2891e4db418aa089821a328554897843a704e320b0b8e12b5332 |
Hashes for quicksectx-0.3.0b5-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e9f4f24c569b91041a968572d5cf8e2b795a87040e728f4be3a1b4327bde043 |
|
MD5 | 75c8a38f073752eb2674f7bb04d49fda |
|
BLAKE2b-256 | f28612fc662a225558028b4dd6d1936f5094fe003334e62fccf2af5a21924757 |
Hashes for quicksectx-0.3.0b5-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e95c2417fbef1d22b71ea5d18af92fd9c6b5540959e23027537221c5f8392cd4 |
|
MD5 | 1aaa6b01c0740bc67c682aa998fdaaa4 |
|
BLAKE2b-256 | cdeee399951ce60396d0944c54bd088c3b94f86ee7de254f9d80a05dd1916735 |
Hashes for quicksectx-0.3.0b5-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29f53ada414ed9c6a0fa9639e15146456ac66d5dcf3119a139dfe067b1ad9920 |
|
MD5 | 94bb9854287021aa720fb03c232115bf |
|
BLAKE2b-256 | 64be1d4c9989e5981375fcf0f7cdeebcdfa231172fb27625f886f01a5f8b20d7 |
Hashes for quicksectx-0.3.0b5-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 03a1d556ba9345bf093cbac7602d8c3bb895ad62dac21353991b11ce4cf48df5 |
|
MD5 | 7b03d48135b2854746b1867ff68cd6c3 |
|
BLAKE2b-256 | 1aeb04f2724062dd030c1abb8d74fc360572ea788518bea41f1fea134d5389c0 |