Skip to content

Convert NaT to nan in date2num #10631

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 1 commit into from
Mar 1, 2018
Merged

Conversation

efiring
Copy link
Member

@efiring efiring commented Feb 28, 2018

PR Summary

Numpy datetime64 uses a flag value for Not a Time ("NaT"). When converting from datetime64 to Matplotlib's datenum, dates.date2num now substitutes np.nan for "NaT".

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@jklymak jklymak self-assigned this Feb 28, 2018
@jklymak
Copy link
Member

jklymak commented Feb 28, 2018

Thanks @efiring. I'll review after the tests have passed.

@jklymak
Copy link
Member

jklymak commented Feb 28, 2018

One of the 3.5 tests doesn't like this change, though oddly other tests are Ok w/ it...

lib/matplotlib/dates.py:442: in date2num

@efiring
Copy link
Member Author

efiring commented Feb 28, 2018

It's failing on a line in the original code, not a line that I added. Numpy version is 1.10 on the failing test. My PR adds the datetime64[ns] to all the checks because that is the variant that Pandas uses--I suspect that is why we are seeing the failure.

>       extra = d - d.astype('datetime64[s]').astype(d.dtype)
E       TypeError: Cannot cast ufunc subtract input from dtype('<M8') to dtype('<M8[s]') with casting rule 'same_kind'

@jklymak
Copy link
Member

jklymak commented Feb 28, 2018

... but the old code has been passing... 🐑

@efiring efiring added this to the v2.2.0 milestone Feb 28, 2018
@efiring
Copy link
Member Author

efiring commented Feb 28, 2018

I know it's late, but I think this is simple enough and important enough to be considered for v2.2.

@jklymak
Copy link
Member

jklymak commented Feb 28, 2018

Agree that this should go in: the datenum64 stuff is new anyways, it should be shipped w/o a missing feature like this if at all possible.

Copy link
Contributor

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

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

Looks good to me. I'll leave it open a bit to let anyone else comment.

@dopplershift dopplershift merged commit 2d14a31 into matplotlib:master Mar 1, 2018
lumberbot-app bot pushed a commit that referenced this pull request Mar 1, 2018
tacaswell added a commit that referenced this pull request Mar 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants