I'm running python 2.7 and numpy 1.15.
I get:
>>> import numpy as np
>>> np.issubdtype(4, float)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/brianp/work/cyan/venv/lib/python2.7/site-packages/numpy/core/numerictypes.py", line 714, in issubdtype
arg1 = dtype(arg1).type
TypeError: data type not understood
Did something change so that it used to work with values, but now it only works with types?
As per an answer below:
>>> np.issubdtype(4, np.float)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/brianp/work/cyan/venv/lib/python2.7/site-packages/numpy/core/numerictypes.py", line 714, in issubdtype
arg1 = dtype(arg1).type
TypeError: data type not understood
I should add that
>>> np.issubdtype(type(4), np.float)
False
works... but the code USED to work without type()
...
Use the numpy types first. Then you want to compare dtypes, not actual values.
>>> np.issubdtype(np.float, np.float)
True
You cannot compare variables, only types.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.