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.2-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a510c46188389d04055a2f694bec4e62d61babbddfc201cfbc63576ecc8da5d0 |
|
MD5 | 318e0fef5b0480521b458a81aeb25773 |
|
BLAKE2b-256 | 15cf05c794e4f4d31b8d31ae68f2f36963852b78d9525a244eaeb93429becbd2 |
Hashes for quicksectx-0.3.2-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9c8bc405dee99860bd415efb9a14b89c41f0782b0ce583506821e8cb2be4e6e |
|
MD5 | 9c29c054341087c1e9d2101659968fbe |
|
BLAKE2b-256 | f6145650eccab11bc1e2df8474e0a00e9d8ef7f0ee2b25e142563057e85a2dce |
Hashes for quicksectx-0.3.2-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43ce1cb95cce9495f883942b1a7739eb2ea4b839a119bcc89d0c79ecd8b2113d |
|
MD5 | 7b51388fa97787d438a89584070c58fd |
|
BLAKE2b-256 | f34ee97b06478fdb6d53c901a589dda7e8ed44f3b7a5ad71db4f4726e1b14dde |
Hashes for quicksectx-0.3.2-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4c371d83eb04553d0407088ab3ca92625770921aed6068a4286ba59e00f0154 |
|
MD5 | f551937f3245b818130a7d0301d5cbf0 |
|
BLAKE2b-256 | c679556c71521938cfd70e2dd885e5f7f5380058a8d7ad7dfb1f8e357aa49d57 |
Hashes for quicksectx-0.3.2-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e2c3c43529c3aeaee89bd9a898bb9c8d723ddb6007e5d09c11cb7e0cbfbc82f |
|
MD5 | cca84e3383efc922031ae5a493a2bdfc |
|
BLAKE2b-256 | c953b9cfb2cab95b35d4ab40d6d4631aab26e16ee395ac626f6733594a3e4fa8 |
Hashes for quicksectx-0.3.2-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ca49764a32f1a6d75d927a673eea9352a9bb830dee25eb87047706ee014e5084 |
|
MD5 | 40bdeb8c95a22f948f580b1f6187552d |
|
BLAKE2b-256 | 0fcfe457b0b8d869f6f2bb699d499809eb6ee480fa30637be1821e50dca469bb |
Hashes for quicksectx-0.3.2-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4d74c9eed8c624838e5bd5868a98b9e74a4e0e5603fa6b314d150dae6e793632 |
|
MD5 | f5d2b03e8b1225b27bef30133482a641 |
|
BLAKE2b-256 | 32def81a34805349fad01460104d3ce87b0b11f676ce11485199efb6802df1a2 |
Hashes for quicksectx-0.3.2-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c88dd5cdad353f04d00377aced1144f9a4680e5d078671723829207015d4e02 |
|
MD5 | 9a167a7da79d76433bcf059d4fbe4b92 |
|
BLAKE2b-256 | fc77a7a14ab04ced100d21baf95fb3c51c92d3655f54c0ccf0f55fe2fb19d7e8 |
Hashes for quicksectx-0.3.2-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3e7cb655393c92049c35593162199bfe8e9d2d282befed540aa12bb9c334d683 |
|
MD5 | 74a219e3763fbe36550fde304a25446a |
|
BLAKE2b-256 | 397af125364519543d791b39c562603520f7a896605ca2e2034fc81c01f1dae6 |
Hashes for quicksectx-0.3.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 887ab91ffdcde8a83ef2a12e3d0efab368392c1752987ad0b9d73ab5b773ff87 |
|
MD5 | 1f691ec02af3543f3037ff53e18abc28 |
|
BLAKE2b-256 | 12f458bd8d52f85f498d897ad237293cc79d2fad369993fafb5b106ade5eeecc |
Hashes for quicksectx-0.3.2-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f0e9f38b25dd159d849a53569b2c9317eaa5d6eb0240086f782235c9d009d00f |
|
MD5 | 4e34b384368695275eec2310fdff0c47 |
|
BLAKE2b-256 | b0986523fe9a446bc7baeea94a33c60e5752e1f7e2536b1c3ab9d1fa48e53bdd |
Hashes for quicksectx-0.3.2-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7dd92b73e2d2faa0a1f4640c8c373381f915b995a2ef57d16cc6b10c2badb41f |
|
MD5 | 80c9393162b91db3edf35e43065febea |
|
BLAKE2b-256 | 2f36bea4945601a8dfa885b44573aa90ca9638bc41a350915f5625b2f9ff7686 |
Hashes for quicksectx-0.3.2-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12a5d2af13c867f55060f15f0b141885b7839871141f06bcbaa1074c471d4fac |
|
MD5 | 739d1e32777264d8f766dee0175ed15d |
|
BLAKE2b-256 | 37ef2a5020aba9eb191f1e5d0f2d3583acecde7a47bb4ca6332fde65886b8945 |
Hashes for quicksectx-0.3.2-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b3c1ea434fc32088a7eda04d6b8ab4812e526583568b457bb7157fb2f271ce6 |
|
MD5 | db56971b65aa2b802252c1a586168896 |
|
BLAKE2b-256 | afe9e1a32b29569cd52f97184dcf19aa059dde36003646cfb002632ced745814 |
Hashes for quicksectx-0.3.2-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5697ef3907fbedb6fa07b7371fc67911d211986e70dda4ef37cd0b26e4b47c75 |
|
MD5 | 9d43d102af14bf745259e36793cf7e76 |
|
BLAKE2b-256 | ed4add728943dad1d1463c343f2ebd44117038dfc2d2d31949c576aaa16f0365 |
Hashes for quicksectx-0.3.2-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bdb78ffa8fd1563d2fe416155684046bfd3129fe1c304e3c4d5547e482cc1b41 |
|
MD5 | f85aaf391d1ad183042c7a379bc00a61 |
|
BLAKE2b-256 | af3439d76579111065b0387bd8ec4efdd36e52c1bf1539fd63747152eba2f1d3 |
Hashes for quicksectx-0.3.2-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9d54daee855b3013bea6421e60cbbc5f4755fa3f256043830917b3cbb4915925 |
|
MD5 | 7981477b1f108d256e789fff7cf4b869 |
|
BLAKE2b-256 | 7f4b26a06e7300f32e48a48ada29b51026f610587f9f9b8dc314d3f02f9c34df |
Hashes for quicksectx-0.3.2-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a464c4035975aa23ca85b2ea8888cc56b38042f1bbb23f8898c38bc8765c23df |
|
MD5 | ec7fa28d087b8c672a3dd7e7ca0ee8f7 |
|
BLAKE2b-256 | e154208006734937b3a6392d55274d60aa565ac551489076dfa466025de32348 |
Hashes for quicksectx-0.3.2-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6313d9054f0e71ff18345b29eca39c5294e07c67edc1b6f6c0d46ddcc3ba1e96 |
|
MD5 | b857c540d06e121a2154299f4891fe8e |
|
BLAKE2b-256 | c79788b8e03a0c9a2e91a04d617ee7d63553bd4caa0d9ee38fec0352f0bb0270 |
Hashes for quicksectx-0.3.2-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 190206178599f49c64d26a29c3580848ce012a7a030a791ab0a3b85c7547af0a |
|
MD5 | 332ba3e41b30ba589ef13bb5f9f42a28 |
|
BLAKE2b-256 | d5d12e82cb301af1ba93454231da1cfdbc59b691b2878527d2162a6e57d456e0 |
Hashes for quicksectx-0.3.2-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfc3a325e30c875b9ab7c700a0005f011675292a8ec1b3886d97642559d1fa9e |
|
MD5 | acab2b82bb39bcc971bae800ec4e4178 |
|
BLAKE2b-256 | 144a4946ed9f289b259fc1208f3e857344f0c542441150db090e5cb6749c641a |
Hashes for quicksectx-0.3.2-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ccc9800592bd7f852a9aa5ff4f9fe4742957ece3af51b3fa84fcb525591b5e00 |
|
MD5 | d38b44bbdd1c332b7a5dfaef339831e4 |
|
BLAKE2b-256 | 4bf30cd308648a253610bc710a585f40179500e8e4a7e23c8b0d68dce4503466 |
Hashes for quicksectx-0.3.2-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bf9cd89b68776a5802825494a90bae454757f87d09f5a8a389778f5e3bef1782 |
|
MD5 | fc7cba0294b74e2bf40366a3dd1deda6 |
|
BLAKE2b-256 | 39dc152385c0ece4f576a980428606301f7964626d38dce763bf9ebede5aa0c3 |
Hashes for quicksectx-0.3.2-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f59226840533bf45f880db9cf0cacc7976a2c656b3285da4f5beafecc339d5c7 |
|
MD5 | f245afc788980d81dc12fbf6951fa106 |
|
BLAKE2b-256 | b937c478f1f32c99abccade19a65c1780ea8de81cd0f324f2dd57c8ba661db97 |
Hashes for quicksectx-0.3.2-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 207e96439b9b928468547d330a4c7276f97d478061e6af4040753477387b153f |
|
MD5 | 5fc59ff0b52b5029ba66bdf03b8ca483 |
|
BLAKE2b-256 | b31c3fe7a24b3e669f85d9d87ec9180e2fa8a245d536ee2ad0f128553ad0db00 |
Hashes for quicksectx-0.3.2-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4c3ea13cd769fd6be31503a45c7ec49b585c69441270aca88d104f34efb6ea07 |
|
MD5 | 6ad7cf6f94f90732a7ea0d5894a64b2e |
|
BLAKE2b-256 | 2563bc9841464b34d0f86b3bd9e47da1a2904923e020f6656cd068a26230dde7 |
Hashes for quicksectx-0.3.2-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7cf4be3ab2ff079c8b0fb2dade5fda6ff46c4e27269bfda222a502ec44167630 |
|
MD5 | 0d864316072759e68c7891ec1271c7b6 |
|
BLAKE2b-256 | f78576ac5379a8aae5af3f6bc73c6acf6b6cd7b10f6ed3713bcb578af404af82 |
Hashes for quicksectx-0.3.2-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f9a6d745ee7b7640295c64e07b768d58a2e732395da1ee00f50ffc907a762e8 |
|
MD5 | 857658c3cf38b489d9b2c75c810fec68 |
|
BLAKE2b-256 | 637552ac5b401c09044a1feb2fff66be2c2173235854b615009cec2ee0c3b303 |
Hashes for quicksectx-0.3.2-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b587bc163d640aa370e07343cad1afe7c1838de8c0864d6d780c741fb313131 |
|
MD5 | c8af057d1f147b78f3bc6d0c39aec1e2 |
|
BLAKE2b-256 | 4ede1390fb3c1d10d60c2f3c3b67e23080fea6f057ddb15a14315343698ee5a4 |
Hashes for quicksectx-0.3.2-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0caa849135b355201044dc03e34e2f32410a82bd6c78d0c894fc2ec243ce432 |
|
MD5 | b1118dae816fe08a8e9cedf4cef9a2c1 |
|
BLAKE2b-256 | 84a7e2262a1f37724532c298aff2c070ef4e2274612be2317c7e10e69958c1fe |
Hashes for quicksectx-0.3.2-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c8a5354e486e008209029f66df585e47d6628a3592b974fcf0a6e906902318a4 |
|
MD5 | 09bfe1f54ddff88fb77eecc0ac613a1f |
|
BLAKE2b-256 | 9e68ac7a6fbd716e2c06367c49e5c8c08ba3fbef751c783efe1fb516a93c80d0 |
Hashes for quicksectx-0.3.2-cp36-cp36m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fd6aaedb50ac32aa9f54f849f623f4bd985047af6e420856ebf8b31a0670da1 |
|
MD5 | 5a2c50bbd9f2f30f5c7d5f12521b271e |
|
BLAKE2b-256 | 5e955d82112157155ad5d276108b8eebf13476efc08d42ee2f3091114023d96f |
Hashes for quicksectx-0.3.2-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42af89f7e85fd6dddc09b4fb78b7f267ddbb8cf493b2f4b43bb9dcfb900b89c1 |
|
MD5 | 932a273def0bf63d279e2ed59428e476 |
|
BLAKE2b-256 | 08aa3f7f8d8c93a0c5c2b0f5e5d6c3f960c2f644ce8f54dec678368f9631c4e4 |
Hashes for quicksectx-0.3.2-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | de32ec6f403b498abda16eb570fc329c598df51a6eaf7313530fee5900568b58 |
|
MD5 | d5d441a96fe5281202d698fe48935d0d |
|
BLAKE2b-256 | 87b3930772ebc6f069ec1ecf6f4e400723bd2af026a8f87b33b4f5c13e09d6e1 |