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

windows - Single EXE to Install Python Standalone Executable for Easy Distribution -

c# - Access objects in UserControl from MainWindow in WPF -

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