Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DEPR: Remove deprecation from private class IntervalTree #47637

Merged
merged 4 commits into from
Jul 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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