TypeError: Cannot cast ufunc add output from dtype('float64') to dtype('uint8') with casting rule 'same_kind'
See original GitHub issueI’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.
File "animation/target_animation.py", line 161, in draw
fill = gizeh.ImagePattern(self.bg.data, self.bg.pos, filter='best')
File "build/bdist.linux-x86_64/egg/gizeh/gizeh.py", line 295, in __init__
File "build/bdist.linux-x86_64/egg/gizeh/gizeh.py", line 50, in from_image
TypeError: Cannot cast ufunc add output from dtype('float64') to dtype('uint8') with casting rule 'same_kind'
Is there a workaround or would you fix this issue please?
Issue Analytics
- State:
- Created 8 years ago
- Reactions:1
- Comments:14 (7 by maintainers)
Top Results From Across the Web
I'm getting a TypeError for a += b, but not b += a (numpy)
Report the whole TypeError! ----> 3 a += b TypeError: Cannot cast ufunc add output from dtype('float64') to dtype('int64') with casting rule ......
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' · Problem:.
Read more >Cannot cast ufunc 'add' output from dtype('x') to ... - CSDN博客
_exceptions.UFuncTypeError: Cannot cast ufunc 'add' output from dtype('float64') to dtype('int64') with casting rule.
Read more >can add int to float but can't add float to int | Sololearn
import numpy as np a = np.full((2,3),3, dtype=int) print(a) ... print(a) 14 TypeError: Cannot cast ufunc add output from dtype('float64') to ...
Read more >numpy.true_divide — NumPy v1.24 Manual
numpy.true_divide(x1, x2, /, out=None, *, where=True, casting='same_kind', order='K', dtype=None, subok=True[, signature, extobj]) = <ufunc 'divide'>#.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
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
Typically this is code such as
a += b
and you need to make itnp.add(a, b, out=a, casting="unsafe")
(if you are sure you want the unsafe cast behaviour. Or, unless b is huge and it is safe, maybe just cast b first.In my case, I had a similar issue. It was solved as suggested by seberg. I replaced line 40 in gizeh.py:
with line:
I hope this helps somebody else.