Skip to content

Commit 36a3d8e

Browse files
committed
Revert "ENH: consistency of input args for boundaries - Interval (pandas-dev#46522)"
This reverts commit 7e23a37.
1 parent bd736e4 commit 36a3d8e

Some content is hidden

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

68 files changed

+670
-1028
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-2
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

doc/source/reference/arrays.rst

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

306-
Interval.inclusive
306+
Interval.closed
307307
Interval.closed_left
308308
Interval.closed_right
309309
Interval.is_empty
@@ -340,7 +340,7 @@ A collection of intervals may be stored in an :class:`arrays.IntervalArray`.
340340
341341
arrays.IntervalArray.left
342342
arrays.IntervalArray.right
343-
arrays.IntervalArray.inclusive
343+
arrays.IntervalArray.closed
344344
arrays.IntervalArray.mid
345345
arrays.IntervalArray.length
346346
arrays.IntervalArray.is_empty

doc/source/reference/indexing.rst

+1-1
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

doc/source/user_guide/advanced.rst

+1-1
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.

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

+1-6
Original file line numberDiff line numberDiff line change
@@ -826,12 +826,6 @@ Other Deprecations
826826
- Deprecated positional arguments to :meth:`Index.join` except for ``other``, use keyword-only arguments instead of positional arguments (:issue:`46518`)
827827
- Deprecated positional arguments to :meth:`StringMethods.rsplit` and :meth:`StringMethods.split` except for ``pat``, use keyword-only arguments instead of positional arguments (:issue:`47423`)
828828
- Deprecated indexing on a timezone-naive :class:`DatetimeIndex` using a string representing a timezone-aware datetime (:issue:`46903`, :issue:`36148`)
829-
- Deprecated the ``closed`` argument in :class:`Interval` in favor of ``inclusive`` argument; In a future version passing ``closed`` will raise (:issue:`40245`)
830-
- Deprecated the ``closed`` argument in :class:`IntervalIndex` in favor of ``inclusive`` argument; In a future version passing ``closed`` will raise (:issue:`40245`)
831-
- Deprecated the ``closed`` argument in :class:`IntervalDtype` in favor of ``inclusive`` argument; In a future version passing ``closed`` will raise (:issue:`40245`)
832-
- Deprecated the ``closed`` argument in :class:`.IntervalArray` in favor of ``inclusive`` argument; In a future version passing ``closed`` will raise (:issue:`40245`)
833-
- Deprecated the ``closed`` argument in :class:`IntervalTree` in favor of ``inclusive`` argument; In a future version passing ``closed`` will raise (:issue:`40245`)
834-
- Deprecated the ``closed`` argument in :class:`ArrowInterval` in favor of ``inclusive`` argument; In a future version passing ``closed`` will raise (:issue:`40245`)
835829
- Deprecated allowing ``unit="M"`` or ``unit="Y"`` in :class:`Timestamp` constructor with a non-round float value (:issue:`47267`)
836830
- Deprecated the ``display.column_space`` global configuration option (:issue:`7576`)
837831
- 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`)
@@ -848,6 +842,7 @@ Other Deprecations
848842
- Deprecated producing a single element when iterating over a :class:`DataFrameGroupBy` or a :class:`SeriesGroupBy` that has been grouped by a list of length 1; A tuple of length one will be returned instead (:issue:`42795`)
849843
- Fixed up warning message of deprecation of :meth:`MultiIndex.lesort_depth` as public method, as the message previously referred to :meth:`MultiIndex.is_lexsorted` instead (:issue:`38701`)
850844
- Deprecated the ``sort_columns`` argument in :meth:`DataFrame.plot` and :meth:`Series.plot` (:issue:`47563`).
845+
-
851846

852847
.. ---------------------------------------------------------------------------
853848
.. _whatsnew_150.performance:

pandas/_libs/interval.pyi

+2-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ 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 (
1312
IntervalClosedType,
1413
Timedelta,
@@ -52,24 +51,19 @@ class IntervalMixin:
5251
def is_empty(self) -> bool: ...
5352
def _check_closed_matches(self, other: IntervalMixin, name: str = ...) -> None: ...
5453

55-
def _warning_interval(
56-
inclusive, closed
57-
) -> tuple[IntervalClosedType, lib.NoDefault]: ...
58-
5954
class Interval(IntervalMixin, Generic[_OrderableT]):
6055
@property
6156
def left(self: Interval[_OrderableT]) -> _OrderableT: ...
6257
@property
6358
def right(self: Interval[_OrderableT]) -> _OrderableT: ...
6459
@property
65-
def inclusive(self) -> IntervalClosedType: ...
60+
def closed(self) -> IntervalClosedType: ...
6661
mid: _MidDescriptor
6762
length: _LengthDescriptor
6863
def __init__(
6964
self,
7065
left: _OrderableT,
7166
right: _OrderableT,
72-
inclusive: IntervalClosedType = ...,
7367
closed: IntervalClosedType = ...,
7468
) -> None: ...
7569
def __hash__(self) -> int: ...
@@ -161,7 +155,7 @@ class IntervalTree(IntervalMixin):
161155
self,
162156
left: np.ndarray,
163157
right: np.ndarray,
164-
inclusive: IntervalClosedType = ...,
158+
closed: IntervalClosedType = ...,
165159
leaf_size: int = ...,
166160
) -> None: ...
167161
@property

0 commit comments

Comments
 (0)