|
| 1 | +""" |
| 2 | +intervaltree: A mutable, self-balancing interval tree for Python 2 and 3. |
| 3 | +Queries may be by point, by range overlap, or by range envelopment. |
| 4 | +
|
| 5 | +Test module: IntervalTree, remove_overlap caused incorrect balancing |
| 6 | +where intervals overlapping an ancestor's x_center were buried too deep. |
| 7 | +Submitted as issue #72 (KeyError raised after calling remove_overlap) |
| 8 | +by alexandersoto |
| 9 | +
|
| 10 | +Copyright 2013-2018 Chaim Leib Halbert |
| 11 | +
|
| 12 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 13 | +you may not use this file except in compliance with the License. |
| 14 | +You may obtain a copy of the License at |
| 15 | +
|
| 16 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 17 | +
|
| 18 | +Unless required by applicable law or agreed to in writing, software |
| 19 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 20 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 21 | +See the License for the specific language governing permissions and |
| 22 | +limitations under the License. |
| 23 | +""" |
| 24 | +from __future__ import absolute_import |
| 25 | +from intervaltree import IntervalTree, Interval |
| 26 | +import pytest |
| 27 | + |
| 28 | +def test_interval_removal_72(): |
| 29 | + tree = IntervalTree([ |
| 30 | + Interval(0.0, 2.588, 841), |
| 31 | + Interval(65.5, 85.8, 844), |
| 32 | + Interval(93.6, 130.0, 837), |
| 33 | + Interval(125.0, 196.5, 829), |
| 34 | + Interval(391.8, 521.0, 825), |
| 35 | + Interval(720.0, 726.0, 834), |
| 36 | + Interval(800.0, 1033.0, 850), |
| 37 | + Interval(800.0, 1033.0, 855), |
| 38 | + ]) |
| 39 | + tree.verify() |
| 40 | + tree.remove_overlap(0.0, 521.0) |
| 41 | + tree.verify() |
| 42 | + |
0 commit comments