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 Distributions
Built Distributions
Hashes for quicksectx-0.3.0b7-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6b3feefb65bdb34813dbe9c8d2fb8af233eda1825c6cc0fedda32714a9663270 |
|
MD5 | 08f11cf39392ec9126d06687a8aa6f55 |
|
BLAKE2b-256 | e9f1118385e28354b96a071d4a92f0cf63f5ab5365cc52d224124bf6974639a0 |
Hashes for quicksectx-0.3.0b7-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1091ebf5d0b7d8dd2909efbb5c38a92209fe5c1f7603297a58286041e948f715 |
|
MD5 | 5e993452295a1a07529ee255181a7056 |
|
BLAKE2b-256 | 543c7fd24a5f11ea696806e75e27929aa2de40e6da6772b6f6169443b2f012f7 |
Hashes for quicksectx-0.3.0b7-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e62a384d41df32e85fff93c8f9f448df3e6141a05223856533bdcd8481eea0d0 |
|
MD5 | 2737e5ef7583042d14aee4318cd92b44 |
|
BLAKE2b-256 | 421025d5ebf096cf1840a6eea6fd9291f5206a86dd47c27fef9b029b7ff781ba |
Hashes for quicksectx-0.3.0b7-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a152eeda73c015b92f49d5ca67406a2b4f1001dd2285119843ae69bb50782207 |
|
MD5 | b2058aacad67eb5e8ce656baf9a21cce |
|
BLAKE2b-256 | 5fc29c76a6462fdde13317c7ee933b2717436a24f85d96f71544a9c7bd616fd1 |
Hashes for quicksectx-0.3.0b7-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e332fc027c2f61b61868453908511cbc2051c70cf43289d82fe499f8abebe54 |
|
MD5 | dae834a919ec8c393109c96849cb7b56 |
|
BLAKE2b-256 | 6ca5e07fc030f2084ff35833c57f4afa6997773f371235fa9136d415de121c48 |
Hashes for quicksectx-0.3.0b7-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | fb3dddc8c26a5d2a74e3baedccae5cf606d329c9c3270a6cad20eaf03ca4bd63 |
|
MD5 | 0c1ae3127207eaa94e0e7edae1b1fbc1 |
|
BLAKE2b-256 | 0bd64e67d0aa8865a99cacaae6f8a945f626e537a56bce6c9253e2e2c785e966 |
Hashes for quicksectx-0.3.0b7-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea8dde4e5e537eb5cfe1c2176cc23d614c3c9bea1aad6d9dea1a1d15ae0df32c |
|
MD5 | 4e80c475575a3897e3a7307cdada3131 |
|
BLAKE2b-256 | b18db0c3c770ec290b1aa0de208f2e99449f118cd85b4921e332481c5127923c |
Hashes for quicksectx-0.3.0b7-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b1b4ad7f317ff76bca5535717c29a2a30096c476bcc3a79ffb0f4c062923dcbf |
|
MD5 | dcab09c4c1d2c6cf45d57042286a1b9e |
|
BLAKE2b-256 | 6f4aac77d377acb4bb6bd6b301a4efc96f339ffe88a45370b7a907af6d18b7d9 |
Hashes for quicksectx-0.3.0b7-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e533fe3cb8c6f9a4a5c5765b8521010f1368e9aecea59c6765d93ed935918af8 |
|
MD5 | e6fe7938a0e6531bae09d94c694621b1 |
|
BLAKE2b-256 | 08f9f5d8cb1893b0e561cdd789366a18c05bb04b74bd739837e3d330ec84d864 |
Hashes for quicksectx-0.3.0b7-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | cfd67b3bfbccd0dcad04fc725f3e4002038cffaa3c101f5a5eda625fdd1c78f3 |
|
MD5 | ae71484cb8a11fce02d6cae5068023d0 |
|
BLAKE2b-256 | 690a2a1d57e19c483068af9e82f2d9883a387c710afe363aa2a084f45b1e4878 |
Hashes for quicksectx-0.3.0b7-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6b3b74d2ef845e324615926c375f10921c5252e9db541a2d0399a3dea0974f0 |
|
MD5 | ed27a0d2982e8f03aacb67e24e753874 |
|
BLAKE2b-256 | 1df33b55887a696107fe114e9f968df5b2eba29f14bfd28489ba6f88a4fbab3a |
Hashes for quicksectx-0.3.0b7-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d4e9d2139d4a0fc118033805658ab7249883ba31633317af57f8627431c2cfee |
|
MD5 | b55b3072c809c9f8acc763319ed277aa |
|
BLAKE2b-256 | b1ccf78c27e5c9dec4b31846c47259a33c33cb7f78f93d8e34d4f100fa56d6a7 |
Hashes for quicksectx-0.3.0b7-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bda74754b3fee6b16c7491a055fd84f3364687e35e7871590f5e08c904ff74fa |
|
MD5 | f50b2f8875eb9bb0a98e4b8be1269f89 |
|
BLAKE2b-256 | e08cadd76ff277b9857b7593f2a94b029519d7d95070306bfeaa440367d932e3 |
Hashes for quicksectx-0.3.0b7-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 83f20fa8c60a7e439c3506e915822ae574053e4962583e93befad35e0eb1b712 |
|
MD5 | 053196663fdb101d86285e215226dc79 |
|
BLAKE2b-256 | 1eaeba4512b3c05a18c006bbb9dff40cc4f0d53b0564f8deefb8c9c9c014079e |
Hashes for quicksectx-0.3.0b7-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df6fabc990708d4f6aee95fed4ac6b18f662745f85c79707f82269bdd7bba385 |
|
MD5 | 1e87acb47bc2a8356743728ebd26e5f5 |
|
BLAKE2b-256 | 06c5e22435256f249e1f16d49f97e1d1fa9332335200b5e580c1fcdc92f922b9 |