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.4.dev1-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4743aea2c98e2f6f5067a88a9fdeb11b2fcf3518c096271a0dcaf3077d2b18d |
|
MD5 | 5674c3c6cd0c102871e42870b93adee6 |
|
BLAKE2b-256 | 18d31ad7d4633525bd0b0cf87b9e4373d77943f2ecbe2ae248c047872709f3a0 |
Hashes for quicksectx-0.3.4.dev1-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 491330e90eec1637f5de74c986fcebc6f8886a89df419db233ae27d2bd5939e9 |
|
MD5 | 48ebed0bd07fd9d0083f50904f042166 |
|
BLAKE2b-256 | 449f377c38dfb47755316e6923d360505da001e2509176a64b9e4c9fcdf1305a |
Hashes for quicksectx-0.3.4.dev1-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2c415438521d180798ecd789caecf719c381e860cc4b1340130597d43b0cba3 |
|
MD5 | b554057935bb7c990ee42a4745801ef5 |
|
BLAKE2b-256 | 1252aee2a46209a9ab90de09f31633691f634a33cf211a820e279765035c110e |
Hashes for quicksectx-0.3.4.dev1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 720349e67b9e72365061a2d7c0d650050da8b308591863cd6abf9fa64aed1d89 |
|
MD5 | cac7421b4083253848e0b5c721a93370 |
|
BLAKE2b-256 | 1c592564ecc90e3ad7a73a518cef8eddb67ade27e961e487ac7288b9b709153d |
Hashes for quicksectx-0.3.4.dev1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6c42d07f63a9c34035908cd65a1d846456bc445701f4e8e14a8cdedd133278c3 |
|
MD5 | 8d7568e19bef0991f5d6354ca8e41aa8 |
|
BLAKE2b-256 | 7e5210abb571805b3a936ecd5b0fa34335bc94c46864eac2ae93ee38d44be0f8 |
Hashes for quicksectx-0.3.4.dev1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 716ad8ac584f48dedc1bb015abd9b3d64c02dc6ad93ab53b7af071d7e39a45ad |
|
MD5 | 9c254add8f0684483ea348d0bc7162e3 |
|
BLAKE2b-256 | 0147797e2eadc25539a483bacf2d52acdb762f8e1944b6a8a710c62fd7af9e62 |
Hashes for quicksectx-0.3.4.dev1-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 745b9736eed95c9652e6290c6b718dfff352d1f2b364dbfadfd83bd5a85fa08c |
|
MD5 | 15cb28a45ab00de4ee5116f7174455ef |
|
BLAKE2b-256 | 15e9b28ac95d1fe0b29dff248cc41ac3e5ae99c7e34eea6d8e53dc5931b4ffea |
Hashes for quicksectx-0.3.4.dev1-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 541620e46b7eda8ca96cef76ba2c7a570dbdaaf2e51cc71b86a43a43731044b3 |
|
MD5 | f9197852a53e805f810c486a0d2d8b8f |
|
BLAKE2b-256 | 772e42f32513766e99a20c763fad9f11ccfc336cb11df9d53f4f087ce94fb97c |
Hashes for quicksectx-0.3.4.dev1-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a981365019c000854989638c56f91dfdf570d3faed3e481596e140075ade7be |
|
MD5 | 6baa1cc926d62687ebd7638ef9f570c9 |
|
BLAKE2b-256 | 9f04af0bfc0835c0696e2ca83bdbe97866e4b7460ccb29c13d420249d1751411 |
Hashes for quicksectx-0.3.4.dev1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | da4051b6f657770b92990f383a6adfb0627470dc43a870fdf807c535ec7d832f |
|
MD5 | e7ce79a54f4245f57ed8ff4f4b6744e4 |
|
BLAKE2b-256 | 1f960ed4d858b029d19b7a8d44fbccffbe54c0f0a9db5dea1eff441321d42cb4 |
Hashes for quicksectx-0.3.4.dev1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e65366b44d58bbeecf586e70f715cabd7d03d6dac250663288a287dbe37d34ca |
|
MD5 | 8e4bd1ed392275e636752222684df5b2 |
|
BLAKE2b-256 | fc8df4a7cf2bd0a78c0015c2276b39370db9d7d51afd52e8a7447812a516f1e8 |
Hashes for quicksectx-0.3.4.dev1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5d690d771c1078ac383f7ce02a63640cdb3af87f18902cb112c9c3cc62d405b8 |
|
MD5 | 01d25e8a63898e385900923e57b8db15 |
|
BLAKE2b-256 | 650e0f7f6dcf39ef4b9453cc6f6b3e7b4f3f634f9d415eee27ee93f61050efa3 |
Hashes for quicksectx-0.3.4.dev1-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1d4e2bb54993c1c5dc046b16c294dde407265665645bc12fabc851355449ae47 |
|
MD5 | ed6c435ee73d5fe1cf1a33f03d0c6b13 |
|
BLAKE2b-256 | 8c0141004f201c97f3d10d4255b004a25d3589126229333ecb06aa9c1132b5c7 |
Hashes for quicksectx-0.3.4.dev1-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2652d709cd83f0cb0c7186c81fb15b287bfdab31405d489863b34c52a94b8052 |
|
MD5 | 03e76f8a94635034c289465953d35ef2 |
|
BLAKE2b-256 | f776512a063a189f6f869a621439832d1031fc785af22b742c7d6d1ee056eeaa |
Hashes for quicksectx-0.3.4.dev1-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1567206178ef8934b5f79aadac578d13dd1535515119f4e20063a9460c633480 |
|
MD5 | 6f0071adc53d14d548d812a472ffa42b |
|
BLAKE2b-256 | 275cc099a7075079d7c3477f434647007c9dfd925ac264eeb2ce1072400e478e |
Hashes for quicksectx-0.3.4.dev1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cf55d5fc74cf2dff18c06c795df34190ff21bbc0777a245e784f700deee640d9 |
|
MD5 | faad67798b223e5ce0336951034fb009 |
|
BLAKE2b-256 | 2c35ba14989aaa74036aed076ca18b173135df645d44ea0e6d53f4f47c204826 |
Hashes for quicksectx-0.3.4.dev1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 41b50127eff3b14f247f9934834703b4449875713ef39960b63b2dd6c2d5f102 |
|
MD5 | 7494a9b484b2951bb4bd1db43e91c445 |
|
BLAKE2b-256 | 3e046a8e41de6a83f7870ce550e09d395643d256eee30b0cc3527e5792c7abde |
Hashes for quicksectx-0.3.4.dev1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e9a2a632a72eacdf0304a8cc93a1094b5d05f9c1fce162ce3fe7e223866933bd |
|
MD5 | c39c800037e36df320a69ba658ab2c4f |
|
BLAKE2b-256 | 604236fe48995f82ae0aa90a08def86ad06ed3081c747aa71bca30ca81ee36d1 |
Hashes for quicksectx-0.3.4.dev1-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 46ef11a0ac1b26e8b93d06bf24e9de18e7a8d7fa09da9ff2e2463d0563fa022a |
|
MD5 | d0e4f09ff7384a4ea033bdfc0d3a6583 |
|
BLAKE2b-256 | 1e77b20273531130ad73113f929e2acf403b620e7e269176e99a1d5c39d459b3 |
Hashes for quicksectx-0.3.4.dev1-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 715d0233bf9d47cc769e1356bc5cd83e2e4dd8f36cc32b0ecc1d39dd37d23ec4 |
|
MD5 | fb7a983c8e94ed93472ada18cd1f9588 |
|
BLAKE2b-256 | e942cb036bc0b8172836b04cba47c96af8aa3a125280d22407128ef3fa04917c |
Hashes for quicksectx-0.3.4.dev1-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55517c185da1266b8d8d74eb4789210a32be946e4f286fc17cb1a0041dd6f272 |
|
MD5 | babe320bf6cc180e5441b54fa072843b |
|
BLAKE2b-256 | f2cdc8cff00b511f7c71b4d973d61a678a1392870838759f221a631608ba9040 |
Hashes for quicksectx-0.3.4.dev1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8c15ac31342e2ca86ca8e8c271cd1fc0e1e2991f973b4f6a2e78a10521202269 |
|
MD5 | f13de909794fce9b160a9155d2ca2961 |
|
BLAKE2b-256 | 59b08046f835ad1b2fd2d080b934be1842f8e3bded382b02c1d26f6eaa764123 |
Hashes for quicksectx-0.3.4.dev1-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1714fd4801735cfb9d063bc23aa03efae5c2f7f98e17928452448472cda7f5c5 |
|
MD5 | 0a4abc3b2c70a8bb7a62f53e366c4d18 |
|
BLAKE2b-256 | 443f67672d862a7fb456e843e7e46c1ec2d55d92bf7cec528c3c64aa6fa3292d |
Hashes for quicksectx-0.3.4.dev1-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f5b6bdf240bd6441388feae828ec055ba47300032038029f28065b8c769834b5 |
|
MD5 | 8bd735da2890eb7b427e73864c418b09 |
|
BLAKE2b-256 | 1655da10b3234fd279b349fb7b58c073caf27f343eccba4c67c37eaf46dc48df |
Hashes for quicksectx-0.3.4.dev1-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0fd91dae8cf6a6d308af47fc73c172757659d0018d6782668dfbdfac445bc690 |
|
MD5 | 1bc692c6c221d5fcaa257b27b471692f |
|
BLAKE2b-256 | 4334a8258e20c2ab48fd60b745c90d80bdae761b9ada840215cc02baf01810b8 |
Hashes for quicksectx-0.3.4.dev1-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b0d17f419337c7d85a3429267438d02fc18c1002ffcb45a29526f564a568b008 |
|
MD5 | f6404361f60cba1247506ba0247f9064 |
|
BLAKE2b-256 | dfab7c252d96800b486505f22509bbf29bb8d72798ddd4308bb840516268600e |
Hashes for quicksectx-0.3.4.dev1-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3485ee4c5d544bd63cd99b8beac1851d0ad858c0d89871a61ebb541a481d0036 |
|
MD5 | a8bfc8b90aad790304f9bea1374fc7f8 |
|
BLAKE2b-256 | 4327a91b3983cc29a83db7ee5f9909f0d52b6b64a97f048386802350d7dbc86e |
Hashes for quicksectx-0.3.4.dev1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3305b1c759ba274ec3de61d3dd70256a71d295395382fe5709148595c0bb9295 |
|
MD5 | faa2eb8d4975145838e366c5ffb57b82 |
|
BLAKE2b-256 | f383e3f3ab5fd608cfb68d2c429eea88831bb96d85af3788180834737dd708d1 |
Hashes for quicksectx-0.3.4.dev1-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb6c07faff3c732a80a85fc0fa10a80eb66d8ed13d74e64eff670c5a141ca97e |
|
MD5 | 59bc0de3b69048596a8075794cb285d6 |
|
BLAKE2b-256 | a686071ae27b1baa12a6ef0bf72d982c969a85c33f189ef70cfda6b82a303a88 |
Hashes for quicksectx-0.3.4.dev1-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a0d039ac92bf630d8c20531550a8c5c690ad7396f0d5441867299aebbaffd0f |
|
MD5 | 873379a3c5bf34005b4f49309f2736b7 |
|
BLAKE2b-256 | 82c558d71b32733ee76cfb7f1725a1253bd7be759fecc693fbd3a30ced3d2ab8 |
Hashes for quicksectx-0.3.4.dev1-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4496c8bb46f9c5c7064eda858fc2107b74904a2b4cb8de4cac9a875906e591b |
|
MD5 | be235e0bbf99224a9ad1f71a4446a54c |
|
BLAKE2b-256 | 2a0e860da49347586f2f3141182ce414e6839a0a0969565699053dbda641e2e5 |
Hashes for quicksectx-0.3.4.dev1-cp36-cp36m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6791ff16944a518cff5de49d9e9be7f858afe4fce3df0223f4984301d918d98d |
|
MD5 | ec132a0ec3a7a869f6dd5722c9b50714 |
|
BLAKE2b-256 | b391a0f989e2f09d1647b2dcaddd771962af206a7ef98c662ba061147cb3ae3c |
Hashes for quicksectx-0.3.4.dev1-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efb98c535ac7f26e5195dc0871283408f8d6638180c18666fe1e14e777e842ae |
|
MD5 | 8bc2d41f9c73c2b527b3e41515f157d5 |
|
BLAKE2b-256 | 15219a4b5fb8b37df46a10a0cc2c688b81e6466013cfb38b693bd488a2e41de2 |
Hashes for quicksectx-0.3.4.dev1-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3615c2cccd5d0236230edfadfe524e134f5baa2aecfd67311649b86406a41ebf |
|
MD5 | 1751e22e53b4bacad78055838219cade |
|
BLAKE2b-256 | 498ad8fe1f0780e215b1138c1a17f36be0e81e26f3edc815c916f17a25089fad |