Skip to content

TST: add test for non UTC datetime split #14042 #32866

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 2 commits into from
Mar 21, 2020
Merged
Changes from 1 commit
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: 19 additions & 0 deletions pandas/tests/indexes/datetimes/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,3 +425,22 @@ def test_index_map(self, name):
((2018,), range(1, 7)), names=[name, name]
)
tm.assert_index_equal(index, exp_index)

def test_split_non_utc(self):
indices = pd.date_range("2016-01-01 00:00:00+0200", freq="S", periods=10)
split_indices = np.split(indices, indices_or_sections=[])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you name these variables result and expected so the comparison below can be

tm.assert_index_equal(result, expected)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there enough functions like np.split to merit a file like tests.indexes.datetimes.test_numpy_compat?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mroeschke right, done.

@jbrockmendel np.split is the only function I know for which such an issue occurred. But this is my first PR for this project so maybe there are others that I haven't noticed.

valid_indices = DatetimeIndex(
[
"2016-01-01 00:00:00+02:00",
"2016-01-01 00:00:01+02:00",
"2016-01-01 00:00:02+02:00",
"2016-01-01 00:00:03+02:00",
"2016-01-01 00:00:04+02:00",
"2016-01-01 00:00:05+02:00",
"2016-01-01 00:00:06+02:00",
"2016-01-01 00:00:07+02:00",
"2016-01-01 00:00:08+02:00",
"2016-01-01 00:00:09+02:00",
]
)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the same as indices but without a a freq, right? if so, can you construct it as

expected = index.copy()
expected._set_freq(None)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks

tm.assert_index_equal(split_indices[0], valid_indices)