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, '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.dev1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebac82ce9e6598817c6c27ce7bb6288abf5fc728a0dc1eb61f2e24bb4efc3929 |
|
MD5 | a38e979f7d6f243ee3d93f0b6d3bba6a |
|
BLAKE2b-256 | ff5d2e6c0d2f9fd6ba78aa82eeec9efa632b78931969612df172b2b035b01f22 |
Hashes for quicksectx-0.3.2.dev1-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d40e44c76b5f31e7e7313f939316db58f91fc5916dc36ddd47df414c5764064b |
|
MD5 | 61d0b126383b8964d34e813ea3dd2a76 |
|
BLAKE2b-256 | a93994421a4b94a4ef74ca707e14c5449f5c015783eb47f0dfe25ee1a0fb6f16 |
Hashes for quicksectx-0.3.2.dev1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 97960070f770e523bb3b861c8183eca1378d851ff33edb5fe892466820f82ba4 |
|
MD5 | 0fb0f93a072a5302fbab554c7fade392 |
|
BLAKE2b-256 | 0972dac4d50106f4a1caa5c9e25ab5ab94498c21a93a4b5a0409ef203dfad3f0 |
Hashes for quicksectx-0.3.2.dev1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d76a54297701e8d8201edcb1da10965c7b2a0137476b214867ec57fcd3e93fe8 |
|
MD5 | d7bf02dec1f65f953bfc9835aa4d1c85 |
|
BLAKE2b-256 | d1101214543b8f5c5167288c44a7fae7a3dedebf72559bce70f5143252cecfae |
Hashes for quicksectx-0.3.2.dev1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2eb9ee5de69da9ca061aef4448be8bba0aac031c9cca6a816692eecb5ceaf24e |
|
MD5 | 4699e20913a18a55b8c3193abdedd5da |
|
BLAKE2b-256 | 588d96df901aa1ad40122a17ad7672e74d58c9ff467ea71f8100baed0eedc098 |
Hashes for quicksectx-0.3.2.dev1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d77258851c4207fbe3ad169038a3cc7171197ebba97cff85f715b04b53f706d7 |
|
MD5 | 35fcacdd24a401870c3317d0239a66ed |
|
BLAKE2b-256 | 436f35e05ee670fb7419086bb06635fb45a79407ae1e300df71246ce08f49cca |
Hashes for quicksectx-0.3.2.dev1-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4ea9e2f536bb15cd26f3c1f4bc9d95d47617744f3f9c2821c144122cb5334d5f |
|
MD5 | dbcfbdf401631f7081cd4ffcf75479b6 |
|
BLAKE2b-256 | d9e8b20ae1de1e46be4292ca75885f2fccda89ed8d4c0c838c1a26cc06cf962b |
Hashes for quicksectx-0.3.2.dev1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89255fdc82145e14636c557e9b0ef56eabfacd183d37a3b0199e7b9f8c6359a1 |
|
MD5 | 6177c53f3cb598de046043cd2bf0820c |
|
BLAKE2b-256 | fdb4ae0706ec7e57cb2a05fb0adcd44fb847e637b0c89941aa1a980d909b319b |
Hashes for quicksectx-0.3.2.dev1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 89251acd86eb60b9c76ec8597e8ec0d3561c7feefea65f3c47492ddd0686ee9a |
|
MD5 | 5d0d7252fde136aa8e99414feb660570 |
|
BLAKE2b-256 | 3402b6f747c5628223d1293a0198cff2ca022a72da4081cab2546d20b6c2c500 |
Hashes for quicksectx-0.3.2.dev1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47b917ef994617ffcf9c5c9ea9da28fc6d30ec5306e0c83b8c7fbf3e910a9cc2 |
|
MD5 | aa4414726b9d57e11843af00747fd036 |
|
BLAKE2b-256 | 82f8222df3ca81d86eb9c1d28d7ff55424808db3ea746e98aaceff74ef1ef2ed |
Hashes for quicksectx-0.3.2.dev1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 13988bb8c09b46772d494fcdc6aa3a71042e5a08f531d8f2477de868faedff68 |
|
MD5 | 49196b88b914c8ff9972685eebfe8276 |
|
BLAKE2b-256 | 46b03af2a47940f5adad048261d6c23ff68e4c2620c95bc4af5f5425298fc2a4 |
Hashes for quicksectx-0.3.2.dev1-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 427702c138c579dee3fc33e52bb6136041bfe8ac4780d95a4f15af10a82caf82 |
|
MD5 | b28f3dc2dda45053442f4430519affc6 |
|
BLAKE2b-256 | 880a91eabe0706b121e471e4fc1512064eacbb2f28b450f01e9019036b114109 |
Hashes for quicksectx-0.3.2.dev1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d3080645650a9fbbb21dba6ee4be72afe5c3244d13266d3c5eca0318603e5aa |
|
MD5 | e5d9bc93f2854316ea2672bd537ec36a |
|
BLAKE2b-256 | 26946df3632c6d02f99a52bc93422dd80c826edbb88591b89b7e8230c5592510 |
Hashes for quicksectx-0.3.2.dev1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb79571c2e7cd65b85b868a0161319938b563c9caecc91c14c475fb37ec2769b |
|
MD5 | 4e7915aa33f3b89587f3fe5c4e5b701e |
|
BLAKE2b-256 | a3a970a696c1c42d05237c7bb3d767652586c3733d8f7df4cdb4f31d26e02f6f |
Hashes for quicksectx-0.3.2.dev1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 08842a01ec1ab51dfa341f652bd7fe286d0a961f9aba74f9286fa0f763df8b36 |
|
MD5 | 625f6ff8d053423d21c8b3abb6cb0f48 |
|
BLAKE2b-256 | 2779f09d443e41cbc7b27c8f29764058f127932ee16cf3999275123cb1329670 |
Hashes for quicksectx-0.3.2.dev1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | eeb19104bfa6a085939c4addec9fbc2fdcc3e84c24fb59c3488ecd6b0833095f |
|
MD5 | 9edf090a57bb60d5c8fb4890dd9e93b1 |
|
BLAKE2b-256 | f6826edd3511ad9f76a014c7537aea478c9ea6b8e7cfcc6e0199965ce819b247 |
Hashes for quicksectx-0.3.2.dev1-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7bfa2f774af98f8551d8b7f2a6d535c1500967103be06a78f98b3fbe4e31e1bb |
|
MD5 | 2453d0baeb7331bb03bc078d5ac31d5c |
|
BLAKE2b-256 | 9105ea6765d5f74aced67583f2e3bd6a7b09de9575c8ce24a60ecdedf7cce1b1 |
Hashes for quicksectx-0.3.2.dev1-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f6178bd5eeb0f38f3b41ce1e044bc33be475492d59a1bf372e7a8e364d2dbb7 |
|
MD5 | c5888f641dcfb2ab0d7b57404bc5d3c6 |
|
BLAKE2b-256 | 12829631d70375edb48dfd3aabad4300e9fefa5e18e0acecee1739c5402e8865 |
Hashes for quicksectx-0.3.2.dev1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d15de156677ab8ed49519258a375dc7d0a49dbfb2acced3e98e49e984893f68b |
|
MD5 | 24af4465d3d57b9a34ae72b5d53af87c |
|
BLAKE2b-256 | 82e3b4347f965cacf65548608214b7da9155fa1e2aba33abc8c18ffd5d4ce18e |
Hashes for quicksectx-0.3.2.dev1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 385a94e8608d02cd4a935458cf158048758c050378acc5a317975546540853cd |
|
MD5 | 8929a5e568d2888f305c40f6bc71a518 |
|
BLAKE2b-256 | c9f3aa33c48547fa41b6446c91670298ebe68233af6103a4a731bdad39724843 |
Hashes for quicksectx-0.3.2.dev1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f59a6b70041bd9255449168b9a9af19d7a8df5d5db3f361f48b3ba407fed19bf |
|
MD5 | b9a0941636068d5f1024f759fdc71d40 |
|
BLAKE2b-256 | 7f59792e341860a449bdab57b750c5d0b00803efd5c4c03c7da207fbde43170f |
Hashes for quicksectx-0.3.2.dev1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 47ca3f7a31151a526280e6b6c66664d616d6e7922c8bd5b8bd11059101393adc |
|
MD5 | e1ec6587a1b3ba1ecbbbf91ae9455f87 |
|
BLAKE2b-256 | 6bda0928094e77a3995c537551bb3232ddacb603d788ae7a54256241d8081e4c |
Hashes for quicksectx-0.3.2.dev1-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f3f949df066a2e3aba49c649096fdee9b1013eb6bf9b1774f0125c6d7f2c7a4a |
|
MD5 | 81eaafabd4777a1fb81617a8ec33b50e |
|
BLAKE2b-256 | 7d46fbcc80c3843faadba1e9391927f3771e702d23f75a34000969cdaa651f62 |
Hashes for quicksectx-0.3.2.dev1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 65c2833b348430d53d64510bb48e200135c47212b5f31be8aedbd4c285d88e97 |
|
MD5 | 56ff4c258d49ba4082064ce841fd94b1 |
|
BLAKE2b-256 | 03453ce3dfd801a09e76ca4d468bfbe8d09d4256d33cdaf71c33abfddcdb8fc6 |
Hashes for quicksectx-0.3.2.dev1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7c5b1a55b8a578bc2e0234f23f842bd7501605e3ed8c083be7bda8b8c2958aa4 |
|
MD5 | e136434d5a8fed4b6f7d9152179f285e |
|
BLAKE2b-256 | 6e8dbe0efdc8a0aaea35c0ade2dfbaca5bc3aeae293777c4af240f843b227ab6 |
Hashes for quicksectx-0.3.2.dev1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a99cb0e7b2badee95ec7863e2612420052640dbb46a66397cebba21fffcb250 |
|
MD5 | d0d6bd5f4d8e75bd34c46543ec9ae594 |
|
BLAKE2b-256 | 9e74742fcc0dfef5ae319b8457507709cedf00caf7208495d08a4353c1d5bc00 |
Hashes for quicksectx-0.3.2.dev1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a54c23dfd9d55be12ff2eba5d17406af3f983b310d5cced6890c3f8d59af1646 |
|
MD5 | 86a853cf0954ed6bd687809e654418a1 |
|
BLAKE2b-256 | de883ecafb68dae51b934bd3b66b33da536e813e8474a2d51d9f9a518b73a822 |
Hashes for quicksectx-0.3.2.dev1-cp36-cp36m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3403356ef1b1bff5d2f63c5f56c0db916c384b2d21499c49546a9d7ef8f2f8a2 |
|
MD5 | 075b60c7da2463ef588ccca30ac3613c |
|
BLAKE2b-256 | 03b4f1befacddf8ac60317a36b7a64bc7001432f1aefba18f346defed06f99ca |
Hashes for quicksectx-0.3.2.dev1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82b6841f37c1d3de7b09d790a5c6156f1ad26f8fd228ab6a4db509cd8bfea319 |
|
MD5 | f53f6ba9514ede418ce2ffd6a7d4fd35 |
|
BLAKE2b-256 | 64587428bac469e7f54750f75842b46e0cf366e927d50c26d210f1f936bf0aa2 |
Hashes for quicksectx-0.3.2.dev1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95c7a62625876e0acb33b828bdafe9fe3ea806039eae7319d012796b1bb50508 |
|
MD5 | 8e5e58267cce75095c5ac7998d6a4470 |
|
BLAKE2b-256 | 315eeeb9267555d9f1d6c23023133b6bd7cab8d741d2ec4f069c9652f0b44058 |