Skip to content

Commit 252ae05

Browse files
mroeschkephofl
andauthored
Revert Interval/IntervalIndex/interval_range.inclusive deprecation (#48116)
* Revert "Cln tests interval wrt inclusive (#47775)" This reverts commit 2d6e0b2. * Revert "CLN: Rename private variables to inclusive (#47655)" This reverts commit 102b3ca. * Revert "TYP: Improve typing interval inclusive (#47646)" This reverts commit 5506476. * Revert "DEPR: Deprecate set_closed and add set_incluive (#47636)" This reverts commit bd4ff39. * Revert "DEPR: Remove deprecation from private class IntervalTree (#47637)" This reverts commit f6658ef. * Revert "Revert inclusive default change of IntervalDtype (#47367)" This reverts commit d9dd128. * Revert "ENH: consistency of input args for boundaries - Interval (#46522)" This reverts commit 7e23a37. * Revert "ENH: consistency of input args for boundaries - pd.interval_range (#46355)" This reverts commit 073b353. * Fix ArrowIntervalType manually * Remove unused import * Fix doctest and leftover usage * Fix remaining tests * Fix wording in doctoring Co-authored-by: Patrick Hoefler <[email protected]>
1 parent 655d9f4 commit 252ae05

File tree

80 files changed

+833
-1408
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

80 files changed

+833
-1408
lines changed

asv_bench/benchmarks/reshape.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,7 @@ def setup(self, bins):
268268
self.datetime_series = pd.Series(
269269
np.random.randint(N, size=N), dtype="datetime64[ns]"
270270
)
271-
self.interval_bins = pd.IntervalIndex.from_breaks(
272-
np.linspace(0, N, bins), "right"
273-
)
271+
self.interval_bins = pd.IntervalIndex.from_breaks(np.linspace(0, N, bins))
274272

275273
def time_cut_int(self, bins):
276274
pd.cut(self.int_series, bins)

doc/redirects.csv

+2-3
Original file line numberDiff line numberDiff line change
@@ -741,11 +741,11 @@ generated/pandas.Index.values,../reference/api/pandas.Index.values
741741
generated/pandas.Index.view,../reference/api/pandas.Index.view
742742
generated/pandas.Index.where,../reference/api/pandas.Index.where
743743
generated/pandas.infer_freq,../reference/api/pandas.infer_freq
744-
generated/pandas.Interval.inclusive,../reference/api/pandas.Interval.inclusive
744+
generated/pandas.Interval.closed,../reference/api/pandas.Interval.closed
745745
generated/pandas.Interval.closed_left,../reference/api/pandas.Interval.closed_left
746746
generated/pandas.Interval.closed_right,../reference/api/pandas.Interval.closed_right
747747
generated/pandas.Interval,../reference/api/pandas.Interval
748-
generated/pandas.IntervalIndex.inclusive,../reference/api/pandas.IntervalIndex.inclusive
748+
generated/pandas.IntervalIndex.closed,../reference/api/pandas.IntervalIndex.closed
749749
generated/pandas.IntervalIndex.contains,../reference/api/pandas.IntervalIndex.contains
750750
generated/pandas.IntervalIndex.from_arrays,../reference/api/pandas.IntervalIndex.from_arrays
751751
generated/pandas.IntervalIndex.from_breaks,../reference/api/pandas.IntervalIndex.from_breaks
@@ -761,7 +761,6 @@ generated/pandas.IntervalIndex.mid,../reference/api/pandas.IntervalIndex.mid
761761
generated/pandas.IntervalIndex.overlaps,../reference/api/pandas.IntervalIndex.overlaps
762762
generated/pandas.IntervalIndex.right,../reference/api/pandas.IntervalIndex.right
763763
generated/pandas.IntervalIndex.set_closed,../reference/api/pandas.IntervalIndex.set_closed
764-
generated/pandas.IntervalIndex.set_inclusive,../reference/api/pandas.IntervalIndex.set_inclusive
765764
generated/pandas.IntervalIndex.to_tuples,../reference/api/pandas.IntervalIndex.to_tuples
766765
generated/pandas.IntervalIndex.values,../reference/api/pandas.IntervalIndex.values
767766
generated/pandas.Interval.left,../reference/api/pandas.Interval.left

doc/source/reference/arrays.rst

+1-3
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,6 @@ Properties
303303
.. autosummary::
304304
:toctree: api/
305305

306-
Interval.inclusive
307306
Interval.closed
308307
Interval.closed_left
309308
Interval.closed_right
@@ -341,7 +340,7 @@ A collection of intervals may be stored in an :class:`arrays.IntervalArray`.
341340
342341
arrays.IntervalArray.left
343342
arrays.IntervalArray.right
344-
arrays.IntervalArray.inclusive
343+
arrays.IntervalArray.closed
345344
arrays.IntervalArray.mid
346345
arrays.IntervalArray.length
347346
arrays.IntervalArray.is_empty
@@ -352,7 +351,6 @@ A collection of intervals may be stored in an :class:`arrays.IntervalArray`.
352351
arrays.IntervalArray.contains
353352
arrays.IntervalArray.overlaps
354353
arrays.IntervalArray.set_closed
355-
arrays.IntervalArray.set_inclusive
356354
arrays.IntervalArray.to_tuples
357355

358356

doc/source/reference/indexing.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ IntervalIndex components
242242
IntervalIndex.left
243243
IntervalIndex.right
244244
IntervalIndex.mid
245-
IntervalIndex.inclusive
245+
IntervalIndex.closed
246246
IntervalIndex.length
247247
IntervalIndex.values
248248
IntervalIndex.is_empty
@@ -251,7 +251,6 @@ IntervalIndex components
251251
IntervalIndex.get_loc
252252
IntervalIndex.get_indexer
253253
IntervalIndex.set_closed
254-
IntervalIndex.set_inclusive
255254
IntervalIndex.contains
256255
IntervalIndex.overlaps
257256
IntervalIndex.to_tuples

doc/source/user_guide/advanced.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ Trying to select an ``Interval`` that is not exactly contained in the ``Interval
10201020
10211021
In [7]: df.loc[pd.Interval(0.5, 2.5)]
10221022
---------------------------------------------------------------------------
1023-
KeyError: Interval(0.5, 2.5, inclusive='right')
1023+
KeyError: Interval(0.5, 2.5, closed='right')
10241024
10251025
Selecting all ``Intervals`` that overlap a given ``Interval`` can be performed using the
10261026
:meth:`~IntervalIndex.overlaps` method to create a boolean indexer.
@@ -1082,14 +1082,14 @@ of :ref:`frequency aliases <timeseries.offset_aliases>` with datetime-like inter
10821082
10831083
pd.interval_range(start=pd.Timedelta("0 days"), periods=3, freq="9H")
10841084
1085-
Additionally, the ``inclusive`` parameter can be used to specify which side(s) the intervals
1086-
are closed on. Intervals are closed on the both side by default.
1085+
Additionally, the ``closed`` parameter can be used to specify which side(s) the intervals
1086+
are closed on. Intervals are closed on the right side by default.
10871087

10881088
.. ipython:: python
10891089
1090-
pd.interval_range(start=0, end=4, inclusive="both")
1090+
pd.interval_range(start=0, end=4, closed="both")
10911091
1092-
pd.interval_range(start=0, end=4, inclusive="neither")
1092+
pd.interval_range(start=0, end=4, closed="neither")
10931093
10941094
Specifying ``start``, ``end``, and ``periods`` will generate a range of evenly spaced
10951095
intervals from ``start`` to ``end`` inclusively, with ``periods`` number of elements

doc/source/whatsnew/v0.20.0.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ Selecting via a specific interval:
448448

449449
.. ipython:: python
450450
451-
df.loc[pd.Interval(1.5, 3.0, "right")]
451+
df.loc[pd.Interval(1.5, 3.0)]
452452
453453
Selecting via a scalar value that is contained *in* the intervals.
454454

doc/source/whatsnew/v0.25.0.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -584,18 +584,18 @@ this would previously return ``True`` for any ``Interval`` overlapping an ``Inte
584584

585585
.. code-block:: python
586586
587-
In [4]: pd.Interval(1, 2, inclusive='neither') in ii
587+
In [4]: pd.Interval(1, 2, closed='neither') in ii
588588
Out[4]: True
589589
590-
In [5]: pd.Interval(-10, 10, inclusive='both') in ii
590+
In [5]: pd.Interval(-10, 10, closed='both') in ii
591591
Out[5]: True
592592
593593
*New behavior*:
594594

595595
.. ipython:: python
596596
597-
pd.Interval(1, 2, inclusive='neither') in ii
598-
pd.Interval(-10, 10, inclusive='both') in ii
597+
pd.Interval(1, 2, closed='neither') in ii
598+
pd.Interval(-10, 10, closed='both') in ii
599599
600600
The :meth:`~IntervalIndex.get_loc` method now only returns locations for exact matches to ``Interval`` queries, as opposed to the previous behavior of
601601
returning locations for overlapping matches. A ``KeyError`` will be raised if an exact match is not found.
@@ -619,7 +619,7 @@ returning locations for overlapping matches. A ``KeyError`` will be raised if a
619619
620620
In [7]: ii.get_loc(pd.Interval(2, 6))
621621
---------------------------------------------------------------------------
622-
KeyError: Interval(2, 6, inclusive='right')
622+
KeyError: Interval(2, 6, closed='right')
623623
624624
Likewise, :meth:`~IntervalIndex.get_indexer` and :meth:`~IntervalIndex.get_indexer_non_unique` will also only return locations for exact matches
625625
to ``Interval`` queries, with ``-1`` denoting that an exact match was not found.
@@ -680,11 +680,11 @@ Similarly, a ``KeyError`` will be raised for non-exact matches instead of return
680680
681681
In [6]: s[pd.Interval(2, 3)]
682682
---------------------------------------------------------------------------
683-
KeyError: Interval(2, 3, inclusive='right')
683+
KeyError: Interval(2, 3, closed='right')
684684
685685
In [7]: s.loc[pd.Interval(2, 3)]
686686
---------------------------------------------------------------------------
687-
KeyError: Interval(2, 3, inclusive='right')
687+
KeyError: Interval(2, 3, closed='right')
688688
689689
The :meth:`~IntervalIndex.overlaps` method can be used to create a boolean indexer that replicates the
690690
previous behavior of returning overlapping matches.

doc/source/whatsnew/v1.5.0.rst

-7
Original file line numberDiff line numberDiff line change
@@ -823,17 +823,10 @@ Other Deprecations
823823
- Deprecated :attr:`Timedelta.freq` and :attr:`Timedelta.is_populated` (:issue:`46430`)
824824
- Deprecated :attr:`Timedelta.delta` (:issue:`46476`)
825825
- Deprecated passing arguments as positional in :meth:`DataFrame.any` and :meth:`Series.any` (:issue:`44802`)
826-
- Deprecated the ``closed`` argument in :meth:`interval_range` in favor of ``inclusive`` argument; In a future version passing ``closed`` will raise (:issue:`40245`)
827826
- Deprecated the methods :meth:`DataFrame.mad`, :meth:`Series.mad`, and the corresponding groupby methods (:issue:`11787`)
828827
- Deprecated positional arguments to :meth:`Index.join` except for ``other``, use keyword-only arguments instead of positional arguments (:issue:`46518`)
829828
- Deprecated positional arguments to :meth:`StringMethods.rsplit` and :meth:`StringMethods.split` except for ``pat``, use keyword-only arguments instead of positional arguments (:issue:`47423`)
830829
- Deprecated indexing on a timezone-naive :class:`DatetimeIndex` using a string representing a timezone-aware datetime (:issue:`46903`, :issue:`36148`)
831-
- Deprecated the ``closed`` argument in :class:`Interval` in favor of ``inclusive`` argument; In a future version passing ``closed`` will raise (:issue:`40245`)
832-
- Deprecated the ``closed`` argument in :class:`IntervalIndex` in favor of ``inclusive`` argument; In a future version passing ``closed`` will raise (:issue:`40245`)
833-
- Deprecated the ``closed`` argument in :class:`IntervalDtype` in favor of ``inclusive`` argument; In a future version passing ``closed`` will raise (:issue:`40245`)
834-
- Deprecated the ``closed`` argument in :class:`.IntervalArray` in favor of ``inclusive`` argument; In a future version passing ``closed`` will raise (:issue:`40245`)
835-
- Deprecated :meth:`.IntervalArray.set_closed` and :meth:`.IntervalIndex.set_closed` in favor of ``set_inclusive``; In a future version ``set_closed`` will get removed (:issue:`40245`)
836-
- Deprecated the ``closed`` argument in :class:`ArrowInterval` in favor of ``inclusive`` argument; In a future version passing ``closed`` will raise (:issue:`40245`)
837830
- Deprecated allowing ``unit="M"`` or ``unit="Y"`` in :class:`Timestamp` constructor with a non-round float value (:issue:`47267`)
838831
- Deprecated the ``display.column_space`` global configuration option (:issue:`7576`)
839832
- Deprecated the argument ``na_sentinel`` in :func:`factorize`, :meth:`Index.factorize`, and :meth:`.ExtensionArray.factorize`; pass ``use_na_sentinel=True`` instead to use the sentinel ``-1`` for NaN values and ``use_na_sentinel=False`` instead of ``na_sentinel=None`` to encode NaN values (:issue:`46910`)

pandas/_libs/interval.pyi

+8-18
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ from typing import (
88
import numpy as np
99
import numpy.typing as npt
1010

11-
from pandas._libs import lib
1211
from pandas._typing import (
13-
IntervalInclusiveType,
12+
IntervalClosedType,
1413
Timedelta,
1514
Timestamp,
1615
)
1716

18-
VALID_INCLUSIVE: frozenset[str]
17+
VALID_CLOSED: frozenset[str]
1918

2019
_OrderableScalarT = TypeVar("_OrderableScalarT", int, float)
2120
_OrderableTimesT = TypeVar("_OrderableTimesT", Timestamp, Timedelta)
@@ -50,31 +49,22 @@ class IntervalMixin:
5049
def open_right(self) -> bool: ...
5150
@property
5251
def is_empty(self) -> bool: ...
53-
def _check_inclusive_matches(
54-
self, other: IntervalMixin, name: str = ...
55-
) -> None: ...
56-
57-
def _warning_interval(
58-
inclusive, closed
59-
) -> tuple[IntervalInclusiveType, lib.NoDefault]: ...
52+
def _check_closed_matches(self, other: IntervalMixin, name: str = ...) -> None: ...
6053

6154
class Interval(IntervalMixin, Generic[_OrderableT]):
6255
@property
6356
def left(self: Interval[_OrderableT]) -> _OrderableT: ...
6457
@property
6558
def right(self: Interval[_OrderableT]) -> _OrderableT: ...
6659
@property
67-
def inclusive(self) -> IntervalInclusiveType: ...
68-
@property
69-
def closed(self) -> IntervalInclusiveType: ...
60+
def closed(self) -> IntervalClosedType: ...
7061
mid: _MidDescriptor
7162
length: _LengthDescriptor
7263
def __init__(
7364
self,
7465
left: _OrderableT,
7566
right: _OrderableT,
76-
inclusive: IntervalInclusiveType = ...,
77-
closed: IntervalInclusiveType = ...,
67+
closed: IntervalClosedType = ...,
7868
) -> None: ...
7969
def __hash__(self) -> int: ...
8070
@overload
@@ -157,15 +147,15 @@ class Interval(IntervalMixin, Generic[_OrderableT]):
157147
def overlaps(self: Interval[_OrderableT], other: Interval[_OrderableT]) -> bool: ...
158148

159149
def intervals_to_interval_bounds(
160-
intervals: np.ndarray, validate_inclusive: bool = ...
161-
) -> tuple[np.ndarray, np.ndarray, IntervalInclusiveType]: ...
150+
intervals: np.ndarray, validate_closed: bool = ...
151+
) -> tuple[np.ndarray, np.ndarray, str]: ...
162152

163153
class IntervalTree(IntervalMixin):
164154
def __init__(
165155
self,
166156
left: np.ndarray,
167157
right: np.ndarray,
168-
inclusive: IntervalInclusiveType = ...,
158+
closed: IntervalClosedType = ...,
169159
leaf_size: int = ...,
170160
) -> None: ...
171161
@property

0 commit comments

Comments
 (0)