Skip to content

TST: Addition test for get_indexer for interval index #47816

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jul 26, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions pandas/tests/indexes/interval/test_interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,12 @@
IntervalIndex,
Timedelta,
Timestamp,
array,
date_range,
interval_range,
isna,
notna,
period_range,
timedelta_range,
)
import pandas._testing as tm
Expand Down Expand Up @@ -924,6 +926,16 @@ def test_interval_index_error_and_warning(self):
with tm.assert_produces_warning(FutureWarning, match=msg_warn):
IntervalIndex.from_tuples([(0, 1), (0.5, 1.5)], closed="both")

@pytest.mark.parametrize("box", [IntervalIndex, array, list])
def test_get_indexer_interval_index(self, box):
# GH#30178
rng = period_range("2022-07-01", freq="D", periods=3)
idx = box(interval_range(Timestamp("2022-07-01"), freq="3D", periods=3))

actual = rng.get_indexer(idx)
expected = np.array([-1, -1, -1], dtype="intp")
tm.assert_numpy_array_equal(actual, expected)


def test_dir():
# GH#27571 dir(interval_index) should not raise
Expand Down