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.5-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b505f1baeac831f115bdef157f1e118a1164938d07fb391e159e49f6037418d |
|
MD5 | 94200969d76c21755cabe69320ab07c8 |
|
BLAKE2b-256 | d7aad161f0e19cf645f2f629bbb1c83fbec366e038edecae9ac83ee3702fe7d0 |
Hashes for quicksectx-0.3.5-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c3d084ddfa7bc39a57c0091c2f8dfcd2266dd3993a5bf04e2592082c0bb016d5 |
|
MD5 | 83a2b9c1a321cc61c0db2130220e759d |
|
BLAKE2b-256 | 21aa41a4635323ba3d5829b53fcad7eeb13aa548970fdae2846a6d6971f76b44 |
Hashes for quicksectx-0.3.5-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34db8e4d8dda2f3f1e073b62da526c270ab8edf114ea239359744489ec474eab |
|
MD5 | ca0a13e70defb9d74f2bf2a61f307ef2 |
|
BLAKE2b-256 | a2afbf9ae41ef987020a716be80547faa9b7f01196973b83ce897be44fcfa770 |
Hashes for quicksectx-0.3.5-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ebea1fcda2ea803f659a5b9775c5c51fcbea98fbb76afe550bbb0cf9d0f99c39 |
|
MD5 | f8f01669f95be2d6fbeb5d197cb15a41 |
|
BLAKE2b-256 | c4fab7544191bfa2954c525220107483e3925347fd613b4ca1d6b3f6522b5806 |
Hashes for quicksectx-0.3.5-cp311-cp311-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7f633a40d5db3938529c9ce2f3cdff47c97aef97b0185c1d2fc206390a2550bd |
|
MD5 | 56947d3c70f920b16a9b03585ff32783 |
|
BLAKE2b-256 | 1f8ce5b27a780280516796c5f1c017417397e66b4c2471d03cc4508089483fa4 |
Hashes for quicksectx-0.3.5-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1969d9e7644ff50589e6c49a7fba92e7b9910d4a10f40bfd7dff19f7cd04988 |
|
MD5 | 8110cadfc58cec9cea3f2c3aea1d6085 |
|
BLAKE2b-256 | c2fa81ddd1b2f7c2e34f1d82eca9fdb0e857788d0c72ee063b803350635e8e40 |
Hashes for quicksectx-0.3.5-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 816331eb6048218725cc9e0780bc55513bacb600a217fd6d821b8581ad5285b7 |
|
MD5 | 6101230c4d4c75c88d2a56867f1388e3 |
|
BLAKE2b-256 | 8b20f7fd7ad5a2cc0c3e74d5a0e5fad0be0198333b3e5b1bbb2d3e8b0a16c3f5 |
Hashes for quicksectx-0.3.5-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2c8ba5b08828bf65c087be9ae22157baccef2b39120d8bbc0cf61666a894caa |
|
MD5 | d90c68e2729ef30c8df46b2688de1554 |
|
BLAKE2b-256 | 0832c2d78323f61ac961a37ef1327844ef30ed308547f26c7d075b98b508d376 |
Hashes for quicksectx-0.3.5-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4839de66f72f883c7b1b04334cd17929597b227d6df7366d0ac4a1bdcab8331a |
|
MD5 | 03231304d98b01af77be096c04841d85 |
|
BLAKE2b-256 | d261e9b1c1a15a8d7e30b1f75f80948b3273a17b7316c06178c2419188b1652d |
Hashes for quicksectx-0.3.5-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 88114449a8726e7cd0e1c0af65ce426a03db8c19da24beb5fb7c5ff4c3cbd1e0 |
|
MD5 | 2a5679e9ba9d5a05421a9e3f39fff8f4 |
|
BLAKE2b-256 | 76cc5282ea50518ce7ddced07d3ea2a79d8cb84de919a09371607c4c7e58e4f9 |
Hashes for quicksectx-0.3.5-cp310-cp310-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b41ca4635edbb6484d3ecb6bc8d822c9f7d69e42509e504ed5e969f5458d0035 |
|
MD5 | bd35552eee9f5b27a9516289b0b6f78e |
|
BLAKE2b-256 | 9946652888876b633f74f1ec295a6acebd26fd0456541be5db772f501ebcccb2 |
Hashes for quicksectx-0.3.5-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7b6a38c9ce335ad6e61edef518119632502254dd9b55c56802850223967a0954 |
|
MD5 | 660dd555481104828eb621878e0d5ded |
|
BLAKE2b-256 | 2af9bb92d9a9fc410eaf2b148b189f438c879d1558a59928c5e2fc9e2d433657 |
Hashes for quicksectx-0.3.5-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 293df114ec9d41122540352ea4c82b690b269344f6e572a85a72ef1cf9696d03 |
|
MD5 | b8a17323b2e2e683a0f2663de1795571 |
|
BLAKE2b-256 | f7ee63f00e38b0f2f84bdb06188d2adad27eb5fa84e9158ee68f4a8ab2f24cab |
Hashes for quicksectx-0.3.5-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a92518f7cfe2c4bb5ed6bfa42a3914995b568325b8a12955d76151d7c059856d |
|
MD5 | 7d034f156ade069289ed4f595149049f |
|
BLAKE2b-256 | e1c4d19ab9ca8fa59878450925013918bf6b18f1ae92f8fd67030a93f430e9d9 |
Hashes for quicksectx-0.3.5-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b2ecd0b0af861145dd3744c1fc5c95fade11a7e1cd1447da5b8333ae9352a404 |
|
MD5 | dca350e344d5f10d25d01cafc20a04e4 |
|
BLAKE2b-256 | 29a468009563cd909b2c2aa13608481583ee757e55392e892ef714a5e66f936e |
Hashes for quicksectx-0.3.5-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a459e19b4077c51d8bb317e531bd4f3964bdd33e8c0f749cdbbb1bfb93c87e07 |
|
MD5 | 653c5e8460e414aaf045b29d8d466c8a |
|
BLAKE2b-256 | 75c8526ba4569adf291dc545e06b01a3ce04ead2920648b2e27efb68cc0a23b6 |
Hashes for quicksectx-0.3.5-cp39-cp39-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2c7c5bb74bdd4ca3b9dd0a3a689f14228d838cd5a1f62cc6209aa10c8fc886b8 |
|
MD5 | da06e7ae0ef82257443d872a078746b7 |
|
BLAKE2b-256 | fcac4896e61c9f724783efe614c01d8f8154c87ad03384bc423e7b2d07775c26 |
Hashes for quicksectx-0.3.5-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e6e925fe1b442c1f6cf973c1ebefd0ad6d5843ac45687b65815ef87fa056c8da |
|
MD5 | 2cc7c24823898533a73885d71c4976e8 |
|
BLAKE2b-256 | d8e716abcc90211af6971bc6045349b9d820293c2a96c76176f681af19192003 |
Hashes for quicksectx-0.3.5-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7952e32162b4783297570f404fbe2ee4f6cdb2310cca8804f5ab1cc57baff48 |
|
MD5 | 73bd33b3b4369bc58acef5adee570ab3 |
|
BLAKE2b-256 | 8bac996f00f5258560d800c2720899e2a97213b92f9fe36a2805f32fd7cc4f31 |
Hashes for quicksectx-0.3.5-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e85d4d1b792f181b3685664ff716dacc21bc5021d8a6300b197908b33534424 |
|
MD5 | be67dcaaa4f863c070d033ea9a458242 |
|
BLAKE2b-256 | a45df500355ff8ed0e8b047af1c3fa6505610201825a4ff34bd4e20645ec72a7 |
Hashes for quicksectx-0.3.5-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 694ef56eef4e14d3c151a11e0b60b73b6b78dd6155da5a8ee6c505ea13f6a1f5 |
|
MD5 | be1d06264dc1df63ce97fb24a1f67c15 |
|
BLAKE2b-256 | 2513479a272b901bdb5ac77325a1b73a38730249945909a532a53200b5bd7700 |
Hashes for quicksectx-0.3.5-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f971a00e2f9352ecca9dbd9e8e91fe9f8bb116a7ecb748353e168f078518ea86 |
|
MD5 | 5b6ae4d62eae18d420cd9113efa1cc5b |
|
BLAKE2b-256 | 19c01b55922ab7e1126ecf030f48e33d1df73c903e8a44aa03e9547cfe3bc4a7 |
Hashes for quicksectx-0.3.5-cp38-cp38-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 338fe418b59f24ce842505575a49464776058f32916a4b790a48acf1b737e176 |
|
MD5 | d808c1090ab5bbbc34690e2ce1235ce0 |
|
BLAKE2b-256 | 73ba07e812b2e80202633d220209495f0ca3cd136403e58a026d25c8eeabcdbe |
Hashes for quicksectx-0.3.5-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ca999ba40338524f56a77715150e91cd63b0ec755a6ea6da96a575501f16d7f |
|
MD5 | beb20ce4a06e6e43cfb1ef6e126a8e01 |
|
BLAKE2b-256 | 0bc4ba53bd89b887bf076edcfbe747f1358e0fc38e9ae2005f360fb8bd7f3177 |
Hashes for quicksectx-0.3.5-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83bb1cd37f21bd6e157f7d83eb9617b8cea1842f93b1cf1e3137733eaada63db |
|
MD5 | d91e5127f1b83393338e919c310c1730 |
|
BLAKE2b-256 | 4b602e27c4813382f087e82f98fa20859351c90f69faced548198644e3a828fd |
Hashes for quicksectx-0.3.5-cp37-cp37m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 53a608ca01cc5212df4554468317b610e2787e79e1bf0d4462ca55340eea835d |
|
MD5 | 43984d5d3d61605b672fa02bea5cc81e |
|
BLAKE2b-256 | 0270c9da990231668b8d0eeadc483d67ab9eb8f97b5559e1fa3d78261337739f |
Hashes for quicksectx-0.3.5-cp37-cp37m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a23600b30ca15b3f39d83e47e653bcd32e422e25fce1e2005ed551acfeae42d6 |
|
MD5 | 2856ac92fa354d2b8d9c84b055978112 |
|
BLAKE2b-256 | ccb2657b591e62c6a2105aa099f71d33a2c35858995a9cb6df318bef931efc7e |
Hashes for quicksectx-0.3.5-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d39b26f0bb2290a9ba40a448400e8e4c37976d4b360979a5f0e373d623add7c0 |
|
MD5 | a4bec4d3f29ed44d86cacc417302e261 |
|
BLAKE2b-256 | c267c706d4c06ddf648965b3879bc2e2df1bcb9f44b85c2868095df02f0eeba0 |
Hashes for quicksectx-0.3.5-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c83b9b28a6a3775e2be8bcc07044804064c258f91f39710dcc5aa63f48968c28 |
|
MD5 | 5869b0e2970c6f89fc32088a6e34293d |
|
BLAKE2b-256 | f21284e2bd437c14935963978d13e03719d9e4526b80c40eade378735a8c9e12 |
Hashes for quicksectx-0.3.5-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 597f469ea6fe4f0e2a6f620c1dd30571daf6ec9d25f61b3580353d7fac48f92c |
|
MD5 | 9cf34f09aeedf99d4e8856de96f50e18 |
|
BLAKE2b-256 | 448dd301d81acb6a6beb022e0605ee9a6c955219303c55d10078549f5117cd86 |
Hashes for quicksectx-0.3.5-cp36-cp36m-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9c48882082c501842e8415b9c62987be6b27ddbc11045e8b875a9fdf22a8452f |
|
MD5 | 4c5f5eebc6c4299e76f5bbe8557bf7e5 |
|
BLAKE2b-256 | 44ce367aa61e2ef27f1ec040e8ef04f7246714af31e47434821e765190811006 |
Hashes for quicksectx-0.3.5-cp36-cp36m-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9dbf4b619d5beaf12ceba61c01d07fcf912ae2a46baecf81b16fcaa698bb7670 |
|
MD5 | 8cc5ad7fa8b55da251108f21c7029e3e |
|
BLAKE2b-256 | 090f56d81f7243ff0cc2048d1b8a2fa342d6a2683aed87d481d34e060961dbb3 |
Hashes for quicksectx-0.3.5-cp36-cp36m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12f41fae95e2db20f2deb20b5257f892000499b6e274aa83ec8993b714635c5a |
|
MD5 | d875210d0ccdebf6dacdfee01cdf8e2e |
|
BLAKE2b-256 | a304676893bdd747b81d0bd9f1e1b656df9f927ecd7e919104cbffd08a5ea968 |
Hashes for quicksectx-0.3.5-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 689f1012af844da1f9ab948e0a34214b45e9b9344ead52c067054eba480e21a2 |
|
MD5 | 9fe3b01b18cf0f8d1723e2813c9a9594 |
|
BLAKE2b-256 | 96fbb87eb874a4858085f4e989b1acd5763c860402f3fa66d7308b676239a6fb |