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 Distribution
Built Distributions
Hashes for quicksectx-0.3.1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f50159dd461beec2c55f0ed27fe908ab6fec37b5429be9f7db57fcf15ba7e2e8 |
|
MD5 | c4e19693d1bcf0a42c0036cb873572e3 |
|
BLAKE2b-256 | e79261bed4d9a716c008821988fb248a8a45bd33992b3dada88a8bb8cc73b3d6 |
Hashes for quicksectx-0.3.1-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5eca3e3abab81b07ac538ca6d59682031388bb78c62e5947437c6b0c6ca39af4 |
|
MD5 | 7fad3a18daea9b08932601e3c1fe6d7e |
|
BLAKE2b-256 | 51269ea7ee83512747c8834f201cf478295b1c7701c0a1c94a18ea67b61cf52a |
Hashes for quicksectx-0.3.1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 76390eba5f4e39c2ad4ff8cc13b3899e7597784fa0c6469f4d6c92500d2bec1a |
|
MD5 | 7f90ba9e7aa51ec0c5495a17883ee5d3 |
|
BLAKE2b-256 | 818366b3198e7174ca073d8f7a09a05c62fa7ae5d2b7b90151d551844dfeb0dd |
Hashes for quicksectx-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b2cd51a73db1dfc209505d09088c505e913c8dd535d676d6c8434a74bc829e1 |
|
MD5 | 4ea0358a8b6e366066b0599c9c7671e3 |
|
BLAKE2b-256 | 7b78a02341a180dc6ba76bcebd221ef0a23a6279862a8fa7fc55195eb3b5a241 |
Hashes for quicksectx-0.3.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bc6252b9927ec7df95346ab2bfff4d189fdb922139057cd9b929379ffa92180 |
|
MD5 | dbf381ae345ef7eac4c46bbbee43fc73 |
|
BLAKE2b-256 | 7c7b28ad49a4c0e4888467c7743e95b8da92fc4988c75efae13f1ec6bea3990c |
Hashes for quicksectx-0.3.1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7fbf0b996dfbe73f548481941e4623fb5d61494f3b1d5b6604645e38dd93feb8 |
|
MD5 | ad6aed32148cc6aa1100d50aa8bf8c7f |
|
BLAKE2b-256 | c209739da81b79c9252ee6bcf34be2c26e53fe89c85f562a71a2534c67dda215 |
Hashes for quicksectx-0.3.1-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43a610079a373149f1aca04b7d3c20565cf6241f0d66df49174f2e256afd1203 |
|
MD5 | 97bbaa5ac4d95ef910692a6311348349 |
|
BLAKE2b-256 | ce4f52ac5161b3ebc0a732b6cf1124f569a319abf061c11e6a89acb3aac708b7 |
Hashes for quicksectx-0.3.1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5c7ae1896c5d5b7dcb2b6ca144b4b7d999e40f60f409b0f8e5bf7aeb19183309 |
|
MD5 | a9824496e1967a859cef7fcbeaa0d91c |
|
BLAKE2b-256 | bd57de018db42d2f041f3f33b29d3660012cf3250e9372ea7e26c2c1539c6342 |
Hashes for quicksectx-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3b55334853b0818f554dd0f50c0a885ad51917e29f88f07b930ec05b7718523 |
|
MD5 | ca6cd20beda5513bed3fe6786811136d |
|
BLAKE2b-256 | d3d53ec279e0260ca9cd4ae3c6c5e53d45dd820ef45b7d34c80762a267ca5f20 |
Hashes for quicksectx-0.3.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | acd68d91f4790cd5b318a3d936fde634f78eb04afbad29300b0b47f16b811882 |
|
MD5 | c6208abaf128cf9533f19c2b4702721d |
|
BLAKE2b-256 | b6dd09b08174bf0b24a050d8d53939e1a3bd4e05908ffe77fbf09f6ee2e336bc |
Hashes for quicksectx-0.3.1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | aa1b62b8b8afa9464abce9f67e299377e88ad28940e09d0e4e41ee2ed5222e81 |
|
MD5 | bcaadbc9b357ff13fe4e686d640e6abd |
|
BLAKE2b-256 | 955c8588994dc0660b99b5530bce1ae344bcc6feed5b420a1d87b73484fad18a |
Hashes for quicksectx-0.3.1-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9e3cfdae1ce4ba7f69fac7c6f999d53362f30591e08b2aa9ce12bb4f8f3e98cd |
|
MD5 | 830c1d59806f8c8b52e7c37c6301f948 |
|
BLAKE2b-256 | b99e16ee34e5d67ea563880d8278b5496093d81e34769e9180847aea332423a3 |
Hashes for quicksectx-0.3.1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a527a8ae0de3aafbf60a142d45d2e9c6745f93a8844b6594e91110cd70d34907 |
|
MD5 | 853230e48ca7286a7e81f4fb67708df7 |
|
BLAKE2b-256 | 00bb1b1edf20ddb67231bb65df5a67fee76bd02d77127ac1cfe38b8f110800b6 |
Hashes for quicksectx-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 063223a2b56c37eb9c12e81fb2587ae401087c6af108d78cb0c327862a139af6 |
|
MD5 | a5bf2d079c71f9bc23d416839222302a |
|
BLAKE2b-256 | a3997e9032d2f44883e83e43215dd0353d1e8ab5312191799eb3c714c93f1873 |
Hashes for quicksectx-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 611c1ff1fe4bbeddd86b06b9bcbdbaa37af768a610d9a470f91b11efb5cecea3 |
|
MD5 | 1d442a815222fee2fd25afcd92b64d94 |
|
BLAKE2b-256 | 9980b6f7c01533e2a6db5814e56c3da5083c8dd654c747c07caeafd2cb75db66 |
Hashes for quicksectx-0.3.1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e409e72750cc32053b1f965df4ffd394673788dee47962458752e703a14354d2 |
|
MD5 | 3ebce7f7da7851de75ec74410b73ef04 |
|
BLAKE2b-256 | 95346d74e56ff2bdaacbe5ce693b4dd84205bdf146b5e7b2c81db25180b29938 |
Hashes for quicksectx-0.3.1-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea713bdbe297693de41fbe016b7867aed474e46070357d5634a6eb848cf989fc |
|
MD5 | ff4b3fa55aebd5d45fd524be284f0a42 |
|
BLAKE2b-256 | c9abea346f932b7a7fd7fb712dec34f32b05c3452449e53ccd2e92956f308ca8 |
Hashes for quicksectx-0.3.1-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4bb62b8a95a155605147d103dcd4be65a5493640d7677bc24748852d87196f83 |
|
MD5 | a51a7ba21c71f92145302e1155796bf4 |
|
BLAKE2b-256 | a4f676e50e3fe9aea592043e46e91ec1f7ea244921747fea423a7330b51c0138 |
Hashes for quicksectx-0.3.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d8f0877c8b25b950e5e02c9ee01cad1b642785e20b75ca3f040c2d3d60a0f88f |
|
MD5 | 35488a7be5e92b297f50fd3b4642f22a |
|
BLAKE2b-256 | 80db4f7dfbdc8ca99f889e4d2a080f595859f95d2dee3e4e067ab5e1ef9de8b5 |
Hashes for quicksectx-0.3.1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 889b475a01760930954a8d7ac3520c7ae0bd268900815f4ad561401bbd49ff06 |
|
MD5 | 3d0b00a598cf2300caf84d407ccd2ead |
|
BLAKE2b-256 | 1ff8a918338dc3ec39cd792d0a80e0efce8a196d2d2a089f6b068e5d872f6e50 |
Hashes for quicksectx-0.3.1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b11ecc66c003231e05a330db0692b82b86fc711032ae35a284c587da22c50f79 |
|
MD5 | ac59aff5ec0e618cad06dd31cf47cbd5 |
|
BLAKE2b-256 | 7d7f3684c86e6d02f7e7fc78e5b8cddc77bf06fd5e65d1b043464858ebebd0ea |
Hashes for quicksectx-0.3.1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b57a135ea033fd9662b02bd722f682a8ca5902b3ed708f43e6c1cd0e4558772d |
|
MD5 | 5700cac9e1d08b6a6a5af46025f8b5c2 |
|
BLAKE2b-256 | c62c11224716c0247c9f0fc0bfd1d50b7996f1ed0d1324984d9fad35688c5e00 |
Hashes for quicksectx-0.3.1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4b8d8151d7733850edf1f8dd5146a3873b504aab7a6d0050f9cac687e9425223 |
|
MD5 | 9950f1a7695c77edb6bf9e5e2013d45a |
|
BLAKE2b-256 | ed7a03f53f7fb26669692c9162e65809f65d0375bb62a3ddec9799bdc96b4c85 |
Hashes for quicksectx-0.3.1-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29ff2b7d4ade72ee983563a57de2adc75aca5c58eb63e2af1bc636acc84005c4 |
|
MD5 | 4fd725a64055aca84a218658b05ef17d |
|
BLAKE2b-256 | 9e2fcec24c9b21063772b412d1fb983abf61d1c66e7dff9350abe65b907813fd |
Hashes for quicksectx-0.3.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3857149a6bb18982f4a924ba706aad46bd06ddc416eecac97d990656a4eb7ad5 |
|
MD5 | 5e063f703f7fdd39dd4f29fec84d3ce7 |
|
BLAKE2b-256 | 3843aa05394ac02b5e3f2140c61d1a50a4a8c8eed57f9ce688c08e8b5c2b6dbf |
Hashes for quicksectx-0.3.1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b04d7fcf3fcf1abddbcebfc8882f6b4f3dddc25a39ef5fdf5c9689f46e66a297 |
|
MD5 | 51992ae2a3c2c146f035ef1a2d268142 |
|
BLAKE2b-256 | 4e9c3f3c7f0ca2886f19fd487d96d8513cbef86598895e1495f78661ad9994b9 |
Hashes for quicksectx-0.3.1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5ad91e933f48b9ec98bc5865edec97550946e443c9bae3cfe7fced8d65b26f66 |
|
MD5 | 2b09271a80ad825fd453903b56dbd451 |
|
BLAKE2b-256 | 6e08f28c7662a6ee43db3c01553cac0b8c1235577d8bb90ad39c51a3a25a96aa |
Hashes for quicksectx-0.3.1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43e6e26e2d5be4316965383be2dedd05e1934cebcef2430b066b9f13ec1df7a7 |
|
MD5 | a5be0739077d31348ced6f887014adf5 |
|
BLAKE2b-256 | 3edcab23b44e739934d31de7e29e059a03f7e8f4ac0c41394939af63bb0e9dd1 |
Hashes for quicksectx-0.3.1-cp36-cp36m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fe9f6c2c9b8d5fb047407a7a772c01f02145c4f5ea554497fdca4d22306f6e3 |
|
MD5 | 84ab5666873559c18a9e34f43f6e5cee |
|
BLAKE2b-256 | d3719048c480d2031d8a75b1ef1d76c285610380aa05011314530f3312b81af5 |
Hashes for quicksectx-0.3.1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b453f8d87c10a236be6b2a268c045e6a2f24d9a95d719d1567e5bda34212427c |
|
MD5 | e3e066ff5f92635e44ae42468f3073d5 |
|
BLAKE2b-256 | 79992fe1a628ae90d7c3c79d521f7e25ea5ed6c0a88d7b86dcbfb2e932555424 |
Hashes for quicksectx-0.3.1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10fac6a1a58941cd65ac8bc6100b3aa7d9bb830824a070353b2da35e5f9aafa2 |
|
MD5 | 2e0d3df5987bada5ccc676fe58808d72 |
|
BLAKE2b-256 | 1bbc7fa3eb59f4f2489f70b19bb1fd82c481e24bfecdda2d9f957d5232013517 |