python - Comparing numpy datatypes to strings -


many numpy functions take dtype arguments either strings (like "float64") or numpy datatypes (like numpy.float64) or python datatypes (like float).

i need compare 2 datatypes , want support flexible interface. there function under of these forms equivalent? i.e. want minimal function f such

f("float64") == f(numpy.float64) == f(float)

what numpy use internally?

you should read scalars page of numpy documentation, describes data type hierarchy.

for comparing dtypes themselves, can use np.issubdtype. examples:

>>> import numpy np >>> np.issubdtype(np.int32, int) true >>> np.issubdtype(np.int32, float) false >>> np.issubdtype(float, np.floating) true >>> np.issubdtype(float, np.inexact) true >>> np.issubdtype(np.float32, float) true >>> np.issubdtype(np.float32, int) false >>> np.issubdtype(np.float32, np.floating) true 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -