Quicksect is a fast python / cython implementation of interval search.
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)]
Since 0.3.7, you can use python’s native pickle to pickle an IntervalTree object. For details, check test_serialization.py
For Dev
Now the version specification has been integrated with setup.py and pyproject.toml. To update versions, only need to change the __version__ in quicksectx/__init__.py
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.9-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3d8ac1276c134a90c2599e19e3465e223c376170b426e3bc5b22528b359f2bf2 |
|
MD5 | 25af7c6796a52ec0ccc181827aebf1df |
|
BLAKE2b-256 | 92f5e0d3aa8efc72c14cc2416e0661971c0fac45b4497a5531ff1a42b52f5c98 |
Hashes for quicksectx-0.3.9-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0acdc4de907cf2891f3b6e23eb4b4eac8e9e08e3cb4f254c06c2ec1923d19dc4 |
|
MD5 | 9cf60043c30aaffa65a44df9d1fb0d3f |
|
BLAKE2b-256 | 6b3b326e932ada300e3f96c09741c10ad758ee1ea0c0e3d2f3d2cbabed48857d |
Hashes for quicksectx-0.3.9-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cdfd0c810847320285aefa11d07397acfa4d8bcb58d74c75094e0744234e09a2 |
|
MD5 | 9d259bca01ccea0e708d7cd7e8b4932b |
|
BLAKE2b-256 | b189191d61a8cf290bdc3b7a9b48b4198f791d6624d4f98ff45f3bb685941174 |
Hashes for quicksectx-0.3.9-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 27ba10b89d94c42bc762bc2716c989a9ae2551e87e5959f00f41719b8387dd4e |
|
MD5 | d4d2163479919d6869dfdecde17d2df5 |
|
BLAKE2b-256 | 5af58d6211ba79f374498ca087bb593f5b68dd6ac0b1c1208509e153b95ed15f |
Hashes for quicksectx-0.3.9-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d2f1533a3e6f26437d749df243fe2bf6d642fa37705725deadd6a3e00b9bb7a |
|
MD5 | 7d64c0ee0ca3979b77901f96be7e62c0 |
|
BLAKE2b-256 | da23f9a0e3ab70af310e5579e90419f72996ae14e5b000f91535fb9ab41abf45 |
Hashes for quicksectx-0.3.9-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 905f80f42ee17574784bc9232cc39d640d555a9b26a71123b6eac2361028e93e |
|
MD5 | 6eb9b61404f05ce9bdc3b7875ab9fea3 |
|
BLAKE2b-256 | 17d6e805026f624f173319e716521f06a330477058fbbd3b324c3040705765da |
Hashes for quicksectx-0.3.9-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0a54cfb682e5121cb943f140928f3f6b04c970b12457afecd9c2e8ab16f90c15 |
|
MD5 | 24be7402e0b124ed5039879aa95bdebe |
|
BLAKE2b-256 | 1f03f9c09b04592d0cac9f7032a467c98caaccd3770d737e2f5b3f0bf1a4ee6e |
Hashes for quicksectx-0.3.9-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 772864cc45f2988c760f82596b1922d27ac09546db56f6e392da0623742e34ae |
|
MD5 | 0bd8d8e124eb472be6d2ea67f48bf5e1 |
|
BLAKE2b-256 | 74ca0d986aac4a883c887db38ca21d84f0f75c1b367e5eb61c390f291ea31520 |
Hashes for quicksectx-0.3.9-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e4ddd1745a923789146bdf238423474075f1eb17e9280da3a63d171857e9660f |
|
MD5 | 3f6ead7f3996b45f57aa7d9b81a8224a |
|
BLAKE2b-256 | 20fb5d1ede991b6645a89e125b92a35317ba9f5b271ac4f382b3d2c26284e0e5 |
Hashes for quicksectx-0.3.9-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fac6d729735270231b72e1da8ead9df346f62901e5b92b2a3eb329000524bbdd |
|
MD5 | c9b315d4b3c7fef382a40560a248a322 |
|
BLAKE2b-256 | 70725fe7cb4736670d6440b9581603604a634c5f4c09e7f823fd050503f3109f |
Hashes for quicksectx-0.3.9-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 125c40535e023da7e7a04f037ea167690da350f6ae2f228825dec5ddaab31b36 |
|
MD5 | 9356473390b611d454e6fe35903de4ad |
|
BLAKE2b-256 | b3d490b741d5d6e849b3be72e3fd2b0d001b5885ce13bc3303080a2b25a673fa |
Hashes for quicksectx-0.3.9-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a8315f8dde1ea974e9f13e58d78538633ba7cf0ac5c98e681b280e249bfd4c3 |
|
MD5 | b859fc3f5ad1994e8544533b0db92302 |
|
BLAKE2b-256 | 5a1b86913a3d8997518222b83583d082ad170af7e006deeccbbac453d0a508ab |
Hashes for quicksectx-0.3.9-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2253aa6dd9320594d889778c9be73fa8a9b3e6520469543a965980fc34ae0e16 |
|
MD5 | af39b4213f0909daeefc75460e1f23ae |
|
BLAKE2b-256 | 41d58d5ad29fec211074109ba1ec2aae32d22acfd42638941d37b395fe3d47af |
Hashes for quicksectx-0.3.9-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8bff819a06b0d4f4c8f1b6fac0231d4eab99f29aa78a303b6efaaf34742b15c1 |
|
MD5 | 9acf66dcc11cbfe9dcad4107f8692ea9 |
|
BLAKE2b-256 | e80972da625af34f33a511766f40feb3ce57af6ab89ffcc564c517052ab21de5 |
Hashes for quicksectx-0.3.9-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4816879c7be287d6494b2b56cbaac65ff23177b2eaaaca15ae23d5684835ad73 |
|
MD5 | d3087935eed1695cbdd08a67cd024f14 |
|
BLAKE2b-256 | 4c1da0e80e216344bb7543f6fa489e4d0a25b66e6c089170260534de29a42f1c |
Hashes for quicksectx-0.3.9-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8ad99896603e2c956632ba9e33bd94313878296bbc9687cdd8f3c0d1a601c451 |
|
MD5 | 26364a5ebcd8d63329acafcb7620208e |
|
BLAKE2b-256 | ad02af175a7964d23d604119ac8ab5edccd2cfc6462fa7801c6932b1e2452559 |
Hashes for quicksectx-0.3.9-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6f8a7a7f9c4a53aa46d323138b165afea25fe7e1fe57d76882cea8e1ec77b63 |
|
MD5 | b642cd35b8406de8adb8edb1131570a1 |
|
BLAKE2b-256 | fe4c38e5273383ecc993b08bc081ec811879cc64edf24b67485ec84a34245920 |
Hashes for quicksectx-0.3.9-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f535075cc51c900d6a8ad71129f6a5e14f5cb7d67873add6eb552051a1663987 |
|
MD5 | ac8507e51f70a16dad5e98aa1fb2e817 |
|
BLAKE2b-256 | e0b7a6efadb215366a82c9cc9899cf0cb9f0b8cde8da4772cdfc0800b0b2dd87 |
Hashes for quicksectx-0.3.9-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d25d0c484203b0c230c5296afc72f4ae80fbbdba987725b344bf8de6f591f65a |
|
MD5 | 7b0b882f751020ac8065d3154f684044 |
|
BLAKE2b-256 | 4f7ab3fe785c59dde5b3e7a55cc2889549b11e56b92ac1694179e25621b87287 |
Hashes for quicksectx-0.3.9-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 71cc443658d0c0b0efaf4626ad9bf177926abb3fce69b263c63e03c2ccf53cee |
|
MD5 | e65547f7145a19714db4b30d59830111 |
|
BLAKE2b-256 | abe35e306f0c44ad33e5154da9a50d4448920da88f0a4d0f13d46895413eb1fa |