ENH: Show unit information in repr for datetime64("NaT")#29396
ENH: Show unit information in repr for datetime64("NaT")#29396ngoldbaum merged 2 commits intonumpy:mainfrom
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.
ngoldbaum
left a comment
There was a problem hiding this comment.
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.
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.
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).