numpy - Consistent way to check if an np.array is datetime-like -


i'm dong unit testing , need make sure function returns np.datetime64-like object. however, can of unit (year, day, nanosecond, etc).

i've tried:

comp = function_returns_datetime_array(inp)  assert isinstance(comp.dtype, np.datetime64) assert issubclass(comp.dtype, np.datetime64) assert issubclass(type(comp.dtype), np.datetime64) 

any suggestions?

you can use issubdtype:

np.issubdtype(comp.dtype, np.datetime64) 

Comments

Popular posts from this blog

javascript - How to name a jQuery function to make a browser's back button work? -

python - Django-easy-pdf: xhtml2pdf reporting reportlab 2.2+ is required, but 3.0 installed -

collision detection - C++ library for mesh to mesh intersection: what is available? -