-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
ENH: Show unit information in repr for datetime64("NaT") #29396
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
ENH: Show unit information in repr for datetime64("NaT") #29396
Conversation
Unlike timedelta objects, datetime64 does not display its unit in the repr output (see numpy#28496). To maintain backward compatibility, this change adds unit information only when the datetime64 object has a NaT value.
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.
Makes sense to me. I think because this changes the repr it needs a release note, see doc/release/upcoming_changes/README.rst
for more info about adding release note blurbs to PRs.
|
||
PyObject *meta = metastr_to_unicode(&scal->obmeta, 1); | ||
if((scal->obval == NPY_DATETIME_NAT) && (meta != NULL)){ | ||
if (legacy_print_mode > 125) { |
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 guess technically we could define a new numpy 2.3 legacy print mode as well. I don't know if it's worth the ceremony just for this.
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.
Thank you for the comment! Defining a new print mode feels like a bit too much as well, but I'm happy to give it a try if needed.
…aT") Add a new release note for the change that shows time unit in the __repr__ output of datetime64("NaT"). See numpygh-29396.
@ngoldbaum |
Let's bring it in. If anyone reads this in the future because of downstream test failures please open an issue and we can reconsider adding a new legacy print mode. |
Thanks @riku-sakamoto |
Overview
np.datetime64("nat", "ms")
does not use unit inrepr
(unlike timedelta) #28496Details
np.datetime64("nat", "ms")
does not use unit inrepr
(unlike timedelta) #28496).