[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] numpy array module now in the pygame development tree



Nice one :)


On Jan 7, 2008 7:57 PM, Marcus von Appen <mva@xxxxxxxxxxxx> wrote:
> On, Sun Jan 06, 2008, Lenard Lindstrom wrote:
>
> > So array2d can handle 24 bit pixels. It is pixels2d that does not. But the
> > test program does raise the following exception when the test surface has
> > 24 bit pixels.
> >
> > Traceback (most recent call last):
> >  File "ac_bug.py", line 6, in <module>
> >    ac = py.numpyarray.array_colorkey(s)  # Raises exception
> >  File "C:\PRG\PYTHON25\lib\site-packages\pygame\numpyarray.py", line 312,
> > in ar
> > ray_colorkey
> >    array = numpy.choose (numpy.equal (array, colorkey), (0xff, 0))
> > ValueError: shape mismatch: objects cannot be broadcast to a single shape
>
> The array_colorkey () method got fixed in SVN rev. 1070. Thanks.
>
> >
> > The code is also inefficient, not making proper use to numpy's type system.
> > Using (numpy.uint8(0xff), numpy.uint8(0)) as the second argument to choose
> > returns an array of uint8.
>
> I do not know anything about the efficiency tweaks in numpy as the
> available documentation lacks such things. I'd have expected it to match
> the type automatically, but for now I changed the function using your
> proposal. Thanks.
>
> Regards
> Marcus
>