-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TST: lock down timeseries now tests, xref #18666 #18709
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 1 commit
75fadb8
e922500
bd9b723
e968a45
af66e44
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 |
---|---|---|
|
@@ -187,6 +187,48 @@ def test_to_datetime_format_weeks(self, cache): | |
|
||
class TestToDatetime(object): | ||
|
||
def test_to_datetime_now(self): | ||
# See GH#18666 | ||
with tm.set_timezone('US/Eastern'): | ||
npnow = np.datetime64('now').astype('datetime64[ns]') | ||
pdnow = pd.to_datetime('now') | ||
pdnow2 = pd.to_datetime(['now'])[0] | ||
# These should all be equal with infinite perf | ||
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. give a little room, I have seen flakiness with these kinds of tests, maybe 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. Confused. You want more room or less room? 1e7 < 1e10. 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. nvm. you are comparing for 10s here. maybe add a comment. |
||
assert abs(pdnow.value - npnow.astype(np.int64)) < 1e10 | ||
assert abs(pdnow2.value - npnow.astype(np.int64)) < 1e10 | ||
|
||
assert pdnow.tzinfo is None | ||
assert pdnow2.tzinfo is None | ||
|
||
def test_to_datetime_today(self): | ||
# See GH#18666 | ||
# Test with one timezone far ahead of UTC and another far behind, so | ||
# one of these will _almost_ alawys be in a different day from UTC. | ||
# Unfortunately this test between 12 and 1 AM Samoa time | ||
# this both of these timezones _and_ UTC will all be in the same day, | ||
# so this test will not detect the regression introduced in #18666. | ||
with tm.set_timezone('Pacific/Auckland'): # 12-13 hours ahead of UTC | ||
nptoday = np.datetime64('today').astype('datetime64[ns]') | ||
pdtoday = pd.to_datetime('today') | ||
pdtoday2 = pd.to_datetime(['today'])[0] | ||
# These should all be equal with infinite perf | ||
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 & add a blank line |
||
assert abs(pdtoday.value - nptoday.astype(np.int64)) < 1e10 | ||
assert abs(pdtoday2.value - nptoday.astype(np.int64)) < 1e10 | ||
|
||
assert pdtoday.tzinfo is None | ||
assert pdtoday2.tzinfo is None | ||
|
||
with tm.set_timezone('US/Samoa'): # 11 hours behind UTC | ||
nptoday = np.datetime64('today').astype('datetime64[ns]') | ||
pdtoday = pd.to_datetime('today') | ||
pdtoday2 = pd.to_datetime(['today'])[0] | ||
# These should all be equal with infinite perf | ||
assert abs(pdtoday.value - nptoday.astype(np.int64)) < 1e10 | ||
assert abs(pdtoday2.value - nptoday.astype(np.int64)) < 1e10 | ||
|
||
assert pdtoday.tzinfo is None | ||
assert pdtoday2.tzinfo is None | ||
|
||
@pytest.mark.parametrize('cache', [True, False]) | ||
def test_to_datetime_dt64s(self, cache): | ||
in_bound_dts = [ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
side issue, do we really need this actual test routine? can't we just inspect the actual output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Best guess is that this is intended to be double-sure that a test specifically hits string_to_dts (since coverage is hard with cython). I'd have no real objection to losing this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah i think ok to remove