From 543865666504415861f4dd0ce555e0d93fc2d8b1 Mon Sep 17 00:00:00 2001 From: patrick Date: Thu, 7 Jul 2022 17:34:10 +0200 Subject: [PATCH 1/4] DEPR: Remove deprecation from private class IntervalTree --- pandas/_libs/intervaltree.pxi.in | 15 +++------------ 1 file changed, 3 insertions(+), 12 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: From 2caf7954b899ba3c98d1779a6996186a736d6c34 Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Fri, 8 Jul 2022 13:32:47 +0200 Subject: [PATCH 2/4] remove test --- .../indexes/interval/test_interval_tree.py | 18 ------------------ 1 file changed, 18 deletions(-) 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", From feafc6a186d15756a50f9961305e36d446f9267e Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Fri, 8 Jul 2022 13:36:23 +0200 Subject: [PATCH 3/4] Add set inclusive --- doc/source/reference/arrays.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/reference/arrays.rst b/doc/source/reference/arrays.rst index 0d8444841fcae..cd0ce581519a8 100644 --- a/doc/source/reference/arrays.rst +++ b/doc/source/reference/arrays.rst @@ -352,6 +352,7 @@ A collection of intervals may be stored in an :class:`arrays.IntervalArray`. arrays.IntervalArray.contains arrays.IntervalArray.overlaps arrays.IntervalArray.set_closed + arrays.IntervalArray.set_inclusive arrays.IntervalArray.to_tuples From 7bb22bc33fa8991b3bd34efbfaee267abe94064c Mon Sep 17 00:00:00 2001 From: Patrick Hoefler Date: Fri, 8 Jul 2022 13:40:37 +0200 Subject: [PATCH 4/4] Revert "Add set inclusive" This reverts commit feafc6a186d15756a50f9961305e36d446f9267e. --- doc/source/reference/arrays.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/source/reference/arrays.rst b/doc/source/reference/arrays.rst index cd0ce581519a8..0d8444841fcae 100644 --- a/doc/source/reference/arrays.rst +++ b/doc/source/reference/arrays.rst @@ -352,7 +352,6 @@ A collection of intervals may be stored in an :class:`arrays.IntervalArray`. arrays.IntervalArray.contains arrays.IntervalArray.overlaps arrays.IntervalArray.set_closed - arrays.IntervalArray.set_inclusive arrays.IntervalArray.to_tuples