From f6658ef9fdef5972214fdc338e2c6b5ee308dbf4 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler <61934744+phofl@users.noreply.github.com> Date: Fri, 8 Jul 2022 14:06:04 -0300 Subject: [PATCH] DEPR: Remove deprecation from private class IntervalTree (#47637) * DEPR: Remove deprecation from private class IntervalTree * remove test * Add set inclusive * Revert "Add set inclusive" This reverts commit feafc6a186d15756a50f9961305e36d446f9267e. --- pandas/_libs/intervaltree.pxi.in | 15 +++------------ .../indexes/interval/test_interval_tree.py | 18 ------------------ 2 files changed, 3 insertions(+), 30 deletions(-) diff --git a/pandas/_libs/intervaltree.pxi.in b/pandas/_libs/intervaltree.pxi.in index 1a6106173e58e..8bf1a53d56dfb 100644 --- a/pandas/_libs/intervaltree.pxi.in +++ b/pandas/_libs/intervaltree.pxi.in @@ -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 @@ -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 @@ -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" @@ -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 @@ -263,7 +254,7 @@ cdef class IntervalNode: # we need specialized nodes and leaves to optimize for different dtype and -# closed values +# inclusive values {{py: diff --git a/pandas/tests/indexes/interval/test_interval_tree.py b/pandas/tests/indexes/interval/test_interval_tree.py index 06c499b9e33f4..6c30d16e61582 100644 --- a/pandas/tests/indexes/interval/test_interval_tree.py +++ b/pandas/tests/indexes/interval/test_interval_tree.py @@ -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",