def test_from_tuples_deprecation_error(): # GH#40245 msg = "Can only specify 'closed' or 'inclusive', not both." with pytest.raises(TypeError, match=msg): with tm.assert_produces_warning(FutureWarning): IntervalArray.from_tuples([(0, 1), (1, 2)], closed="right", inclusive="right")
def test_shift(self): # https://github.com/pandas-dev/pandas/issues/31495, GH#22428, GH#31502 a = IntervalArray.from_breaks([1, 2, 3]) result = a.shift() # int -> float expected = IntervalArray.from_tuples([(np.nan, np.nan), (1.0, 2.0)]) tm.assert_interval_array_equal(result, expected)
def test_repr(): # GH 25022 arr = IntervalArray.from_tuples([(0, 1), (1, 2)]) result = repr(arr) expected = ("<IntervalArray>\n" "[(0, 1], (1, 2]]\n" "Length: 2, dtype: interval[int64, right]") assert result == expected
def data_for_grouping(): a = (0, 1) b = (1, 2) c = (2, 3) return IntervalArray.from_tuples([b, b, None, None, a, a, b, c])
def data_missing_for_sorting(): return IntervalArray.from_tuples([(1, 2), None, (0, 1)])
def data_for_sorting(): return IntervalArray.from_tuples([(1, 2), (2, 3), (0, 1)])
def data_missing(): """Length 2 array with [NA, Valid]""" return IntervalArray.from_tuples([None, (0, 1)])
def data_for_grouping(): a = (0, 1) b = (1, 2) c = (2, 3) return IntervalArray.from_tuples([b, b, None, None, a, a, b, c])
def data_missing_for_sorting(): return IntervalArray.from_tuples([(1, 2), None, (0, 1)])
def data_for_sorting(): return IntervalArray.from_tuples([(1, 2), (2, 3), (0, 1)])
def data_missing(): """Length 2 array with [NA, Valid]""" return IntervalArray.from_tuples([None, (0, 1)])
def test_from_tuples_deprecation(): # GH#40245 with tm.assert_produces_warning(FutureWarning): IntervalArray.from_tuples([(0, 1), (1, 2)], closed="right")