Skip to content

TST/CLN: remove try block from test_indexing_over_size_cutoff_period_index #27276

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
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
28 changes: 12 additions & 16 deletions pandas/tests/series/indexing/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,28 +604,24 @@ def test_indexing_over_size_cutoff():
_index._SIZE_CUTOFF = old_cutoff


def test_indexing_over_size_cutoff_period_index():
def test_indexing_over_size_cutoff_period_index(monkeypatch):
# GH 27136

old_cutoff = _index._SIZE_CUTOFF
try:
_index._SIZE_CUTOFF = 1000
monkeypatch.setattr(_index, "_SIZE_CUTOFF", 1000)

n = 1100
idx = pd.period_range("1/1/2000", freq="T", periods=n)
assert idx._engine.over_size_threshold
n = 1100
idx = pd.period_range("1/1/2000", freq="T", periods=n)
assert idx._engine.over_size_threshold

s = pd.Series(np.random.randn(len(idx)), index=idx)
s = pd.Series(np.random.randn(len(idx)), index=idx)

pos = n - 1
timestamp = idx[pos]
assert timestamp in s.index
pos = n - 1
timestamp = idx[pos]
assert timestamp in s.index

# it works!
s[timestamp]
assert len(s.loc[[timestamp]]) > 0
finally:
_index._SIZE_CUTOFF = old_cutoff
# it works!
s[timestamp]
assert len(s.loc[[timestamp]]) > 0


def test_indexing_unordered():
Expand Down