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

Re: [pygame] Exception in _numpysurfarray.py



On, Fri Apr 11, 2008, Lenard Lindstrom wrote:

> Marcus von Appen wrote:
>> On, Fri Apr 11, 2008, Lenard Lindstrom wrote:
>> 
>>   
>>> Lorenz Quack wrote:
>>>     
>> 
>> [...]
>>   
>>>> The patch may have been a bit premature:
>>>> The person who initially reported this problem to me tells me that with 
>>>> this fix applying changes to the pixels3d array does not change the 
>>>> original surface. I guess that numpy.reshape() making a copy does cause 
>>>> problems in some cases. I'm out of ideas how to go about this...
>>>> 
>>>>       
>>> That's peculiar.
>>> 
>>>     
>>>>>> import numpy
>>>>>> help(numpy.ndarray.reshape)
>>>>>>           
>>> Help on method_descriptor:
>>> 
>>> reshape(...)
>>>    a.reshape(d1, d2, ..., dn, order='c')
>>> 
>>>    Return a new array from this one.  The new array must have the same 
>>> number
>>>    of elements as self.  Also always returns a view or raises a 
>>> ValueError if
>>>    that is impossible.
>>> 
>>> 
>>> Unless I am mistaken a view is an array that references another array.
>>>     
>> 
>> pydoc numpy.reshape:
>>   Help on function reshape in numpy:
>> 
>>   numpy.reshape = reshape(a, newshape, order='C')
>>     Returns an array containing the data of a, but with a new shape.
>>     [...]
>>     *Returns*:
>>       reshaped_array : array
>>           This will be a new view object if possible; otherwise, it will
>>           return a copy.
>> 
>> Attached you'll find the second try to get rid of this issue. Can you
>> please test it? It (once more) works well for me :-).
>> 
>>   
> I haven't tested your patch, but do have an experimental variation on 
> _numpysurfarray. Calling numpy.ndarray directly is what I did as well. Your 
> code matches mine. The tricky part is getting the strides right.

Not that hard. Take a look at the strides settings of
_numericsurfarray.c. Now we just have to wait for Lorenz' feedback :-).

Regards
Marcus

Attachment: pgpRQ9w5I0VVf.pgp
Description: PGP signature