Skip to content

Commit

Permalink
DEPR: Remove deprecation from private class IntervalTree (pandas-dev#…
Browse files Browse the repository at this point in the history
…47637)

* DEPR: Remove deprecation from private class IntervalTree

* remove test

* Add set inclusive

* Revert "Add set inclusive"

This reverts commit feafc6a.
  • Loading branch information
phofl committed Jul 8, 2022
1 parent 16e9b1e commit f6658ef
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 30 deletions.
15 changes: 3 additions & 12 deletions pandas/_libs/intervaltree.pxi.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import warnings
from pandas._libs import lib
from pandas._libs.algos import is_monotonic

from pandas._libs.interval import _warning_interval

ctypedef fused int_scalar_t:
int64_t
float64_t
Expand Down Expand Up @@ -42,18 +40,13 @@ cdef class IntervalTree(IntervalMixin):
object _is_overlapping, _left_sorter, _right_sorter
Py_ssize_t _na_count

def __init__(self, left, right, inclusive: str | None = None, closed: None | lib.NoDefault = lib.no_default, leaf_size=100):
def __init__(self, left, right, inclusive: str | None = None, leaf_size=100):
"""
Parameters
----------
left, right : np.ndarray[ndim=1]
Left and right bounds for each interval. Assumed to contain no
NaNs.
closed : {'left', 'right', 'both', 'neither'}, optional
Whether the intervals are closed on the left-side, right-side, both
or neither. Defaults to 'right'.

.. deprecated:: 1.5.0

inclusive : {"both", "neither", "left", "right"}, optional
Whether the intervals are closed on the left-side, right-side, both
Expand All @@ -66,8 +59,6 @@ cdef class IntervalTree(IntervalMixin):
to brute-force search. Tune this parameter to optimize query
performance.
"""
inclusive, closed = _warning_interval(inclusive, closed)

if inclusive is None:
inclusive = "right"

Expand Down Expand Up @@ -119,7 +110,7 @@ cdef class IntervalTree(IntervalMixin):
if self._is_overlapping is not None:
return self._is_overlapping

# <= when both sides closed since endpoints can overlap
# <= when inclusive on both sides since endpoints can overlap
op = le if self.inclusive == 'both' else lt

# overlap if start of current interval < end of previous interval
Expand Down Expand Up @@ -263,7 +254,7 @@ cdef class IntervalNode:


# we need specialized nodes and leaves to optimize for different dtype and
# closed values
# inclusive values

{{py:

Expand Down
18 changes: 0 additions & 18 deletions pandas/tests/indexes/interval/test_interval_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,24 +190,6 @@ def test_construction_overflow(self):
expected = (50 + np.iinfo(np.int64).max) / 2
assert result == expected

def test_interval_tree_error_and_warning(self):
# GH 40245

msg = (
"Deprecated argument `closed` cannot "
"be passed if argument `inclusive` is not None"
)
with pytest.raises(ValueError, match=msg):
left, right = np.arange(10), [np.iinfo(np.int64).max] * 10
IntervalTree(left, right, closed="both", inclusive="both")

msg = "Argument `closed` is deprecated in favor of `inclusive`"
with tm.assert_produces_warning(
FutureWarning, match=msg, check_stacklevel=False
):
left, right = np.arange(10), [np.iinfo(np.int64).max] * 10
IntervalTree(left, right, closed="both")

@pytest.mark.xfail(not IS64, reason="GH 23440")
@pytest.mark.parametrize(
"left, right, expected",
Expand Down

0 comments on commit f6658ef

Please sign in to comment.