Thanks to visit codestin.com
Credit goes to github.com

Skip to content

np.datetime('NaT') == np.datetime('NaT', 'us') is no longer True on NumPy 1.10 #6452

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

Closed
shoyer opened this issue Oct 12, 2015 · 1 comment
Closed

Comments

@shoyer
Copy link
Member

shoyer commented Oct 12, 2015

I'm not quite sure exactly what happened, but whereas np.datetime64('NaT') == np.datetime64('NaT', 'us') is True on NumPy 1.9, it's False on NumPy 1.10.

I tested this out on a few NumPy/Python versions, and in some cases this comparison results in warnings. In particular:

  • Python 2.7, NumPy 1.9: True / No warning
  • Python 3.4, NumPy 1.9: True / DeprecationWarning: Implicitly casting between incompatible kinds. In a future numpy release, this will raise an error. Use casting="unsafe" if this is intentional.
  • Python 2.7, NumPy 1.10: False / DeprecationWarning: elementwise == comparison failed; this will raise an error in the future.
  • Python 3.4, NumPy 1.10: False / No warning

Based on git blame, it looks like the latest deprecation warning introduced by @njsmith in #5964.

xref pydata/xarray#618

@shoyer
Copy link
Member Author

shoyer commented Oct 12, 2015

This seems like a bug in the datetime64 casting rules for generic time units. I'm working on a fix.

ssanderson pushed a commit to quantopian/zipline that referenced this issue Jan 22, 2016
Fixes lots of ambiguous calls to `np.full` where the result value was
float but the input was an integer, all of which were throwing
FutureWarnings.

Also works around numpy/numpy#6452 by using
NaT values with explicit units.
ssanderson pushed a commit to quantopian/zipline that referenced this issue Jan 22, 2016
Fixes lots of ambiguous calls to `np.full` where the result value was
float but the input was an integer, all of which were throwing
FutureWarnings.

Also works around numpy/numpy#6452 by using
NaT values with explicit units.
shoyer added a commit to shoyer/numpy that referenced this issue May 24, 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

No branches or pull requests

1 participant