Skip to content

What's the best way to assert DataArray's dtype? #4856

Answered by andersy005
ahuang11 asked this question in Q&A
Discussion options

You must be logged in to vote

It's my understanding that due to the complexity of hierarchy of type objects in Numpy, using np.issubdtype() is more reliable/robust than .isinstance():

In [18]: np.issubdtype(ds.air.dtype, np.float32)
Out[18]: True

In [19]: np.issubdtype(ds.time.dtype, np.datetime64)
Out[19]: True

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@keewis
Comment options

@shoyer
Comment options

@ahuang11
Comment options

Answer selected by dcherian
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants