-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
ENH: infer Timestamp unit in non-iso paths #51039
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
Conversation
def test_constructor_str_infer_reso(self): | ||
# non-iso8601 path | ||
ts = Timestamp("2016-01-01 1:30:01 PM") | ||
assert ts.unit == "s" | ||
|
||
ts = Timestamp("2016 June 3 15:25:01.345") | ||
assert ts.unit == "ms" |
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.
I think we need 3 tests here, one for each path inside parse_datetime_string
:
dt = _parse_delimited_date(date_string, dayfirst, out_bestunit)
_parse_dateabbr_string(
dt = dateutil_parse(date_string, default=_DEFAULT_DATETIME,
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.
good idea, updated
# non-iso8601 path | ||
|
||
# _parse_delimited_date path | ||
ts = Timestamp("2023/01/30") |
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.
this hits the iso path, you'll need
ts = Timestamp("01/30/2023")
also, would prefer to parametrise these - you can put _parse_delimited_date path
(and the others) as id
for the different cases
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.
updated to use the suggested string. didnt parametrize - on the margin id like to slow the growth of the pytest overhead
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.
just out of interest, why?
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.
pytest collects something like 200k tests and last time i checked that added up to more than 1GB before we even start executing any tests. Similarly autouse fixtures get called for each test which means that much more overhead at runtime (i haven't measured this so assume it is a small-but-adds-up amount).
Doing a little bit more inside the tests and a little bit less outside can trim that footprint and overhead. Adding a couple cases here isn't a big deal, but on the margin i try to get in the habit of leaning against parametrization when it isn't a compelling use case.
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.
Looks good, thanks @jbrockmendel
doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.