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 Distribution
Built Distributions
Hashes for quicksectx-0.3.0b8-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63ee0ad4e017d8c6623da39e7a028f6d29255e4040c748506ad08ff0e1074b9d |
|
MD5 | d610f87ab10a0d8936049075be598404 |
|
BLAKE2b-256 | 49a997fa061efe0cd57095452bc343f80528de3e2d7adef0f8398cf00b436ce9 |
Hashes for quicksectx-0.3.0b8-cp38-cp38-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3537f61cc95ff49f7b6838755601394d032cae8178065655de5e8f6c783eca89 |
|
MD5 | e94d27bb08104ee2776458fa3e12565d |
|
BLAKE2b-256 | 15f6733c5a548ae4e64c2f38040f96687c106a3945d2238231ba5472cf3718ba |
Hashes for quicksectx-0.3.0b8-cp38-cp38-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6638a6b4c88dc9ada3bb3b374d67beda66fc909929b0ebb5d32f8ff0e4fef9e |
|
MD5 | 00da409cd1a42a5d71a3af6031646977 |
|
BLAKE2b-256 | c49e5f3274a7f4df6f3879ec6da9aa457c84b550ac89c9fb5457554e482e9625 |
Hashes for quicksectx-0.3.0b8-cp38-cp38-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a2fb4ff60ba0cadc24d586013de61bdda79caff8df42861e4d3e571606084046 |
|
MD5 | 3fc0d72144c5ef8a530663a43a85a20c |
|
BLAKE2b-256 | 29afff05387dbb8e2af61a4f1794b7568244c57fe9bb6d7e1e47c0b79407696a |
Hashes for quicksectx-0.3.0b8-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01382fecb434314d11ec837ebf1d93eaa2c9bd794f53ce58bcc968e6ecc55d91 |
|
MD5 | 1dbfa7db984e42bf8060949fdf4ef561 |
|
BLAKE2b-256 | c92abf626c00e4478136e7f10f644645c2512979a0b7b3c77499a4857051cdd8 |
Hashes for quicksectx-0.3.0b8-cp37-cp37m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d22ea104d958e2b52b5324ac3348ec1798b1e45e7a3ac81e139099673e9207db |
|
MD5 | 86e01647b4685eba5910d15bf98b2748 |
|
BLAKE2b-256 | 03fc9d0aa83c1705deac556962c9f36d6b0e0678e086477d4d6f16f39f20125c |
Hashes for quicksectx-0.3.0b8-cp37-cp37m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 21786d7cf2479f28f4bed7166caf2969671c029b4548db4cf0e455034c3ea52d |
|
MD5 | 1362fe5c0d74a5551bd1fc3b8c7d5b47 |
|
BLAKE2b-256 | 4aa2bcb743a71fdfea1d95734ad4dbaf00d0676e22ac0c1839a9b04750799036 |
Hashes for quicksectx-0.3.0b8-cp37-cp37m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d11428888224a248d3501325752836d102f5c3d3daa4390770f0ba6a126e78f6 |
|
MD5 | 52adc27714052ebd7307ab533a319574 |
|
BLAKE2b-256 | 7febdf30b895077ad0212495680b156c2114d585f01385259908eb352826a8f5 |
Hashes for quicksectx-0.3.0b8-cp37-cp37m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c07582319762bb9bf73e6e0996e5fb0cb5b26d12a7413b076b86d2892a3df84b |
|
MD5 | 81db7bf57c648520a919f7c9977e06a2 |
|
BLAKE2b-256 | 1cae41f2a7d0db5c457a8a2c09ef73e88351719cdae686d665f5369c4c1144fb |
Hashes for quicksectx-0.3.0b8-cp37-cp37m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b7fec38ee6e236992f7a01fb47b6d5a89b65f1168198203b2bd8dfcba84728e4 |
|
MD5 | 99ae50e138fa9182690a1b5c9d14e208 |
|
BLAKE2b-256 | bdac422b46b647d22df000bbabea6cf62b5aa0d1e9b537db41c288e3171afb12 |
Hashes for quicksectx-0.3.0b8-cp36-cp36m-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 23bf629a6968674a66fe215bb0d21426a89b83203aae80fc9abe673c1778a7ff |
|
MD5 | 2c73e5f44bfa6cc52814f177947d2a13 |
|
BLAKE2b-256 | cf24d41a2ff3c9b133a5cfd3e8e9c88ce6db1547b9021b9c646aae964cf6d62c |
Hashes for quicksectx-0.3.0b8-cp36-cp36m-manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 858962d48938e99087937cb500f47d5d33b47695c0f064699ad28a813420cf99 |
|
MD5 | b516b9cbd98730afc5d6b1f0c3ab8371 |
|
BLAKE2b-256 | 3ba6a605482f2eef29f6a844e276032e0f79105c86ce5ba26448e0c39bc56912 |
Hashes for quicksectx-0.3.0b8-cp36-cp36m-manylinux1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a1581af3eea7af21e3db4945bbeaf6a2df55e3b70fce7f20fd08fe724ca4162f |
|
MD5 | b63450365f95f30d98cc546967193c79 |
|
BLAKE2b-256 | 19ad96c832602c74557be7c2507b3795320e8507dd68d94f1ea291a955c36694 |
Hashes for quicksectx-0.3.0b8-cp36-cp36m-manylinux1_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 92fd553c0f3c8f2fd4865ac29497d9f106490d6852c27754f1879a8389421498 |
|
MD5 | 597b86c6f38929109f2eded6c1d2e09a |
|
BLAKE2b-256 | b9362aaa755d9e2a628d142707d3380ead2345d755d5876298f87466d9d4a148 |
Hashes for quicksectx-0.3.0b8-cp36-cp36m-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 64c5339173333bd6dd2d8a448a3f115834ce8199b5b037997de9deef601109d8 |
|
MD5 | 6e192a605a3c4eae55da10c1c26dad00 |
|
BLAKE2b-256 | 16d37d237170609922db2a4f7f704b8fa95aa6703536846365154207c40c3e1c |