Hello i have a verry simple problem. but i don't understand what cause the problem.
I have the following python(3) script. i have numpy 1.13.1(an old one but my problem with dtype
should work).
according to this the dtype exist in ufunc
since 1.6
import numpy as np
M=1001
N = 2 ** np.ceil(np.log2(M))
N
Out[252]: 1024.0
2 ** np.ceil(np.log2(M),dtype=int)
Traceback (most recent call last):
File "<ipython-input-253-4b982a04c884>", line 1, in <module>
2 ** np.ceil(np.log2(M),dtype=int)
TypeError: No loop matching the specified signature and casting
was found for ufunc ceil
2 ** np.ceil(np.log2(M),dtype=float)
Out[254]: 1024.0
2 ** np.ceil(np.log2(M),dtype=np.float64)
Out[256]: 1024.0
2 ** np.ceil(np.log2(M),dtype=np.float32)
Out[257]: 1024.0
2 ** np.ceil(np.log2(M),dtype=np.int64)
Traceback (most recent call last):
File "<ipython-input-258-9902fa43f3ac>", line 1, in <module>
2 ** np.ceil(np.log2(M),dtype=np.int64)
TypeError: No loop matching the specified signature and casting
was found for ufunc ceil
2 ** np.ceil(np.log2(M),dtype=np.int32)
Traceback (most recent call last):
File "<ipython-input-259-8a2f2834384f>", line 1, in <module>
2 ** np.ceil(np.log2(M),dtype=np.int32)
TypeError: No loop matching the specified signature and casting
was found for ufunc ceil
As you can see when i change the dtype
to int
, int32
or int64
it fails. Probably anything other than float
fails. I would guess this shouldn't do that!
I can add a small fix so that int(np.ceil(...))
the result is what i want.
I want to know what cause this problem? Since i don't read anything in the numpy reference manual about any issue with this(numpy reference ceil).
If Possible to do solve this problem that it works the way i started
Thanks