question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add `isfinite` support for `datetime64` and `timedelta64`

See original GitHub issue

numpy.isfinite should support datetime64 and timedelta64 objects. It should return True for any ordinary value, and False for datetime64('NaT') and timedelta64('NaT').

As a side-effect, this will make isclose and allclose usable for datetime64 and timedelta64 objects.

In [97]: numpy.isfinite(numpy.datetime64(10**9, 's'))
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-97-8555b18406e5> in <module>()
----> 1 numpy.isfinite(numpy.datetime64(10**9, 's'))

TypeError: ufunc 'isfinite' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:6
  • Comments:28 (17 by maintainers)

github_iconTop GitHub Comments

1reaction
rabernatcommented, Jun 11, 2016

I just hit this bug. I hope it can be fixed.

0reactions
concretevitamincommented, Mar 5, 2019

@eric-wieser Sure - make ndarray of datetime64 function more like first-class citizen will be welcome!

Read more comments on GitHub >

github_iconTop Results From Across the Web

MatPlotLib, datetimes, and TypeError: ufunc 'isfinite' not ...
The problem is, that the numpy ufunc isfinite is not defined for the numpy.datetime64 dtype. There is an effort to change this, though....
Read more >
Datetimes and Timedeltas — NumPy v1.24 Manual
New in version 1.7.0. Starting in NumPy 1.7, there are core array data types which natively support datetime functionality. The data type is...
Read more >
What's new in 1.4.0 (January 22, 2022) - Pandas
Add support for assigning values to by argument in DataFrame.plot.hist() and ... Bug in Index.insert() for inserting np.datetime64 , np.timedelta64 or tuple ...
Read more >
Source code for bokeh.util.serialization - Bokeh documentation
Period) DATETIME_TYPES.add(type(pd.NaT)) NP_EPOCH = np.datetime64(0, 'ms') NP_MS_DELTA = np.timedelta64(1, 'ms') DT_EPOCH = dt.datetime.utcfromtimestamp(0) ...
Read more >
Release Notes — Numba 0.56.4+0.g288a38bbd.dirty-py3.7 ...
PR #7047: Support __hash__ for numpy.datetime64 (Guilherme Leobas ... PR #7082: Added Add/Sub between datetime64 array and timedelta64 scalar (Nick ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found