Skip to content

Commit

Permalink
DEPR: Remove previously deprecated IntervalIndex.from_intervals (#27793)
Browse files Browse the repository at this point in the history
  • Loading branch information
jschendel authored and jreback committed Aug 7, 2019
1 parent 820e09e commit 6cde0b3
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 89 deletions.
1 change: 1 addition & 0 deletions doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Removal of prior version deprecations/changes
- :meth:`pandas.Series.str.cat` now defaults to aligning ``others``, using ``join='left'`` (:issue:`27611`)
- :meth:`pandas.Series.str.cat` does not accept list-likes *within* list-likes anymore (:issue:`27611`)
- Removed the previously deprecated :meth:`ExtensionArray._formatting_values`. Use :attr:`ExtensionArray._formatter` instead. (:issue:`23601`)
- Removed the previously deprecated ``IntervalIndex.from_intervals`` in favor of the :class:`IntervalIndex` constructor (:issue:`19263`)

.. _whatsnew_1000.performance:

Expand Down
44 changes: 0 additions & 44 deletions pandas/core/arrays/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,50 +358,6 @@ def from_arrays(cls, left, right, closed="right", copy=False, dtype=None):
left, right, closed, copy=copy, dtype=dtype, verify_integrity=True
)

_interval_shared_docs[
"from_intervals"
] = """
Construct an %(klass)s from a 1d array of Interval objects
.. deprecated:: 0.23.0
Parameters
----------
data : array-like (1-dimensional)
Array of Interval objects. All intervals must be closed on the same
sides.
copy : boolean, default False
by-default copy the data, this is compat only and ignored
dtype : dtype or None, default None
If None, dtype will be inferred
..versionadded:: 0.23.0
See Also
--------
interval_range : Function to create a fixed frequency IntervalIndex.
%(klass)s.from_arrays : Construct an %(klass)s from a left and
right array.
%(klass)s.from_breaks : Construct an %(klass)s from an array of
splits.
%(klass)s.from_tuples : Construct an %(klass)s from an
array-like of tuples.
Examples
--------
>>> pd.%(qualname)s.from_intervals([pd.Interval(0, 1),
... pd.Interval(1, 2)])
%(klass)s([(0, 1], (1, 2]],
closed='right', dtype='interval[int64]')
The generic Index constructor work identically when it infers an array
of all intervals:
>>> pd.Index([pd.Interval(0, 1), pd.Interval(1, 2)])
%(klass)s([(0, 1], (1, 2]],
closed='right', dtype='interval[int64]')
"""

_interval_shared_docs[
"from_tuples"
] = """
Expand Down
16 changes: 0 additions & 16 deletions pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,22 +269,6 @@ def from_arrays(
)
return cls._simple_new(array, name=name)

@classmethod
@Appender(_interval_shared_docs["from_intervals"] % _index_doc_kwargs)
def from_intervals(cls, data, closed=None, name=None, copy=False, dtype=None):
msg = (
"IntervalIndex.from_intervals is deprecated and will be "
"removed in a future version; Use IntervalIndex(...) instead"
)
warnings.warn(msg, FutureWarning, stacklevel=2)
with rewrite_exception("IntervalArray", cls.__name__):
array = IntervalArray(data, closed=closed, copy=copy, dtype=dtype)

if name is None and isinstance(data, cls):
name = data.name

return cls._simple_new(array, name=name)

@classmethod
@Appender(_interval_shared_docs["from_tuples"] % _index_doc_kwargs)
def from_tuples(cls, data, closed="right", name=None, copy=False, dtype=None):
Expand Down
29 changes: 0 additions & 29 deletions pandas/tests/indexes/interval/test_construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,32 +421,3 @@ def test_index_mixed_closed(self):
result = Index(intervals)
expected = Index(intervals, dtype=object)
tm.assert_index_equal(result, expected)


class TestFromIntervals(TestClassConstructors):
"""
Tests for IntervalIndex.from_intervals, which is deprecated in favor of the
IntervalIndex constructor. Same tests as the IntervalIndex constructor,
plus deprecation test. Should only need to delete this class when removed.
"""

@pytest.fixture
def constructor(self):
def from_intervals_ignore_warnings(*args, **kwargs):
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
return IntervalIndex.from_intervals(*args, **kwargs)

return from_intervals_ignore_warnings

def test_deprecated(self):
ivs = [Interval(0, 1), Interval(1, 2)]
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False):
IntervalIndex.from_intervals(ivs)

@pytest.mark.skip(reason="parent class test that is not applicable")
def test_index_object_dtype(self):
pass

@pytest.mark.skip(reason="parent class test that is not applicable")
def test_index_mixed_closed(self):
pass

0 comments on commit 6cde0b3

Please sign in to comment.