gizeh icon indicating copy to clipboard operation
gizeh copied to clipboard

gizeh.ImagePattern broke using Numpy ver 10

Open dessskris opened this issue 8 years ago • 3 comments

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'

I tried reporting this issue to numpy but they said the gizeh code needs to be modified: You need to make the cast explicit using the casting argument in the np.add ufunc. That is casting='unsafe'.

Would you fix this issue please? I would like to use gizeh and the latest version of numpy.

dessskris avatar Mar 24 '16 17:03 dessskris

For ref: https://github.com/numpy/numpy/issues/7225

alexbw avatar Apr 15 '16 15:04 alexbw

It can be fixed by modifying line 50 in "gizeh.py" from:

  arr += image.flatten()

to:

    #arr += image.flatten()
    np.add(arr, image.flatten(), out=arr, casting="unsafe")

mantielero avatar Apr 09 '17 14:04 mantielero

Pull request #32 should fix this issue.

bitblomster avatar Jan 30 '18 15:01 bitblomster