ufunc cannot be cast with rule `same_kind`
See original GitHub issueUpdgrading to 1.10, I noticed the following new behavior:
In [1]: import numpy as np
In [2]: a = np.array([1,2,3])
In [3]: b = 2.0
In [4]: a /= b
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-4-b9f4626d3ca8> in <module>()
----> 1 a /= b
TypeError: ufunc 'true_divide' output (typecode 'd') could not be coerced to provided output parameter (typecode 'l') according to the casting rule ''same_kind''
In [5]: a = a/b
In [6]: a
Out[6]: array([ 0.5, 1. , 1.5])
See also https://github.com/nipy/dipy/issues/730. Is this an intended new behavior? If so, what does it portend (what should I stop doing?)?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:17
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Cannot cast ufunc add output from dtype('float64') to ... - GitHub
I'm using Gizeh library and I get the above error upon installing the latest version of Numpy. There was no error with Numpy...
Read more >UFuncTypeError: Cannot cast ufunc 'det' input from dtype('O ...
UFuncTypeError : Cannot cast ufunc 'det' input from dtype('O') to dtype('float64') with casting rule 'same_kind'? How to avoid this issue?
Read more >How to fix numpy TypeError: Cannot cast ufunc subtract output ...
How to fix numpy TypeError: Cannot cast ufunc subtract output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
Read more >NEP 43 — Enhancing the extensibility of UFuncs - NumPy
It makes a new distinction between the ufunc which can operate on many ... includes the “same-kind” cast and is thus not considered...
Read more >Array API — NumPy v1.9 Manual
Force a cast to the output type even if it cannot be done safely. ... The rule is that scalars of the same...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Probably means you didn’t see the deprecation warnings since forever 😉 If you want to cast the float result to integer, you can call
true_divide
without=a
andcasting='unsafe'
arguments.I got this error while executing this line : X = preprocess_input(X, mode=‘tf’)
I fixed this error by changing tools versions : Numpy – 1.16.1 Pandas – 0.23.0 Matplotlib – 2.2.2 Keras – 2.2.4
hope this would help.