-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeError: Cannot cast ufunc add output from dtype('float64') to dtype('uint8') with casting rule 'same_kind' #7225
Comments
You need to make the cast explicit using the |
That is |
where should i change this @charris ? |
Typically this is code such as |
I get that I was talking specifically for the changes to be made to gizeh/moviepy . |
In my case, I had a similar issue. It was solved as suggested by seberg. I replaced line 40 in gizeh.py: arr += image.flatten() with line: arr = np.add(arr, image.flatten(), out=arr, casting="unsafe") I hope this helps somebody else. |
I had this issue when subtracting like this: My error went away when I did the subtraction via numpy.subtract, like so: Thanks a lot @seberg 👍 |
@FilipSavic95: Could also do |
@eric-wieser Yeah, I've just tried your solution and it works. Thanks for posting it. 👍 |
The question is which precision you want to use for the operation itself. the unsafe casting will do the operation in the larger (rhs) precision (or the combined safe dtype) the other option will do the cast and thus the operation in the lower precision. |
This is a downstream issue (see Zulko/gizeh#25), so closing. |
Hello, looking for this specific error with search engines usually leads to the solutions above, either on this issue here or on StackExchange. However I've encountered it differently using I had a massive array containing huge integers, as well as an array of indices and another of values to insert in the first. If you go by : a = np.arange(100)
b = np.array([12, 25, 3, 0, 46, 87])
c = np.array([7, 99, 97, 85, 23, 45])
np.insert(a, b, c) ...there's no problem, values of However, if the indices array has
Cast indices array to int64 to solve : I didn't understand why the error was mentioning float64 whereas everything was uint64. I was trying to look for uint64 overflow or some other weird implicit conversion before I realized indices must be signed int64. Hope it'll help if someone else gets here for the same reason. |
What you are seeing is that |
Indeed, I was so pissed when I realized I'd lost so much time for this |
I'm using Gizeh library and I get the above error upon installing the latest version of Numpy. There was no error with Numpy version 1.08.
Is there a workaround or would you fix this issue please?
The text was updated successfully, but these errors were encountered: