Skip to content

Fix typos in test_interval_new.py #20026

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 1 commit into from
Mar 7, 2018
Merged
Changes from all 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
19 changes: 9 additions & 10 deletions pandas/tests/indexing/interval/test_interval_new.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import pytest
import numpy as np
import pandas as pd

from pandas import Series, IntervalIndex, Interval
import pandas.util.testing as tm
Expand Down Expand Up @@ -170,17 +169,17 @@ def test_loc_with_overlap(self):

# interval
expected = 0
result = s.loc[pd.interval(1, 5)]
result = s.loc[Interval(1, 5)]
tm.assert_series_equal(expected, result)

result = s[pd.interval(1, 5)]
result = s[Interval(1, 5)]
tm.assert_series_equal(expected, result)

expected = s
result = s.loc[[pd.interval(1, 5), pd.Interval(3, 7)]]
result = s.loc[[Interval(1, 5), Interval(3, 7)]]
tm.assert_series_equal(expected, result)

result = s[[pd.interval(1, 5), pd.Interval(3, 7)]]
result = s[[Interval(1, 5), Interval(3, 7)]]
tm.assert_series_equal(expected, result)

with pytest.raises(KeyError):
Expand All @@ -197,17 +196,17 @@ def test_loc_with_overlap(self):

# slices with interval (only exact matches)
expected = s
result = s.loc[pd.interval(1, 5):pd.Interval(3, 7)]
result = s.loc[Interval(1, 5):Interval(3, 7)]
tm.assert_series_equal(expected, result)

result = s[pd.interval(1, 5):pd.Interval(3, 7)]
result = s[Interval(1, 5):Interval(3, 7)]
tm.assert_series_equal(expected, result)

with pytest.raises(KeyError):
s.loc[pd.interval(1, 6):pd.Interval(3, 8)]
s.loc[Interval(1, 6):Interval(3, 8)]

with pytest.raises(KeyError):
s[pd.interval(1, 6):pd.Interval(3, 8)]
s[Interval(1, 6):Interval(3, 8)]

# slices with scalar raise for overlapping intervals
# TODO KeyError is the appropriate error?
Expand All @@ -217,7 +216,7 @@ def test_loc_with_overlap(self):
def test_non_unique(self):

idx = IntervalIndex.from_tuples([(1, 3), (3, 7)])
s = pd.Series(range(len(idx)), index=idx)
s = Series(range(len(idx)), index=idx)

result = s.loc[Interval(1, 3)]
assert result == 0
Expand Down