-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
REF: tighten what we accept in TimedeltaIndex._simple_new #31315
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
Changes from 11 commits
13b6fe8
4477131
a09884f
02e9f79
8034d43
13facbc
9cce216
92d4d7e
c1a56a8
9c90e2d
aa2668c
cfa9d79
b30aafa
4fe9849
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -106,7 +106,9 @@ def test_resample_empty_series(freq, empty_series, resample_method): | |
if isinstance(s.index, PeriodIndex): | ||
expected.index = s.index.asfreq(freq=freq) | ||
else: | ||
expected.index = s.index._shallow_copy(freq=freq) | ||
idx = s.index | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as above, why not just collapse this so: we don't need to have the shallow copy used like this in tests, nor work-arounds like this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. implemented a helper _asfreq_compat for this, cleans up some code nicely |
||
index = type(idx)([], dtype=idx.dtype, freq=freq, name=idx.name) | ||
expected.index = index | ||
tm.assert_index_equal(result.index, expected.index) | ||
assert result.index.freq == expected.index.freq | ||
tm.assert_series_equal(result, expected, check_dtype=False) | ||
|
@@ -122,7 +124,9 @@ def test_resample_count_empty_series(freq, empty_series, resample_method): | |
if isinstance(empty_series.index, PeriodIndex): | ||
index = empty_series.index.asfreq(freq=freq) | ||
else: | ||
index = empty_series.index._shallow_copy(freq=freq) | ||
idx = empty_series.index | ||
index = type(idx)([], dtype=idx.dtype, freq=freq, name=idx.name) | ||
|
||
expected = pd.Series([], dtype="int64", index=index, name=empty_series.name) | ||
|
||
tm.assert_series_equal(result, expected) | ||
|
@@ -144,7 +148,9 @@ def test_resample_empty_dataframe(empty_frame, freq, resample_method): | |
if isinstance(df.index, PeriodIndex): | ||
expected.index = df.index.asfreq(freq=freq) | ||
else: | ||
expected.index = df.index._shallow_copy(freq=freq) | ||
idx = df.index | ||
index = type(idx)([], dtype=idx.dtype, freq=freq, name=idx.name) | ||
expected.index = index | ||
tm.assert_index_equal(result.index, expected.index) | ||
assert result.index.freq == expected.index.freq | ||
tm.assert_almost_equal(result, expected, check_dtype=False) | ||
|
@@ -165,7 +171,8 @@ def test_resample_count_empty_dataframe(freq, empty_frame): | |
if isinstance(empty_frame.index, PeriodIndex): | ||
index = empty_frame.index.asfreq(freq=freq) | ||
else: | ||
index = empty_frame.index._shallow_copy(freq=freq) | ||
idx = empty_frame.index | ||
index = type(idx)([], dtype=idx.dtype, freq=freq, name=idx.name) | ||
expected = pd.DataFrame({"a": []}, dtype="int64", index=index) | ||
|
||
tm.assert_frame_equal(result, expected) | ||
|
@@ -184,7 +191,8 @@ def test_resample_size_empty_dataframe(freq, empty_frame): | |
if isinstance(empty_frame.index, PeriodIndex): | ||
index = empty_frame.index.asfreq(freq=freq) | ||
else: | ||
index = empty_frame.index._shallow_copy(freq=freq) | ||
idx = empty_frame.index | ||
index = type(idx)([], dtype=idx.dtype, freq=freq, name=idx.name) | ||
expected = pd.Series([], dtype="int64", index=index) | ||
|
||
tm.assert_series_equal(result, expected) | ||
|
Uh oh!
There was an error while loading. Please reload this page.