[Numpy-discussion] Ransom Proposals
Tim Hochberg
tim.hochberg at cox.net
Tue Mar 28 07:40:06 CST 2006
Tim Hochberg wrote:
> Travis Oliphant wrote:
>
>> Charles R Harris wrote:
>>
>>> Tim,
>>>
>>>
>>> That being said I have a suggestion that *might* satisfy
>>> everyone. Set
>>> the WRITEABLE flag to false if reshape creates a new array:
>>>
>>> I think this will cause problems as I myself usually want to modify
>>> the contents after a reshape. Why not in this case have
>>> a.reshape(...) return a view when possible and raise an error
>>> otherwise, and have the functional form make a copy. Reshape the
>>> method then provides a path to efficient computing, while reshape
>>> the function promotes safe computing. I like to write classes in C++
>>> where I can do things like
>>> b.mul(c).add(d).div(e) all inplace for efficiency and the current
>>> situation strikes me as similar.
>>>
>> This is the direction I could support. If we did this, then the
>> ravel method would also have to change to be consistent.
>>
>> The functions would be copy-if-necessary and would *not* be deprecated.
>>
>> To summarize
>>
>> on making methods that return views raise an error when impossible
>> and not changing and/or deprecating functions (i.e. the functions are
>> simple wrappers around the methods).
>>
>> -1
>>
>> on making methods that return views raise an error when impossible
>> and changing the function to make a copy
>>
>> +0
>
>
> +1 Assuming I understand all of the implications.
>
> * When doing automated conversion from Numeric/numarray to numpy,
> "reshape(obj) => asarray(obj).reshape()". Doing anything else is going
> to cause breakage and/or massive slowdowns. Can the conversion tool
> handle this? I would guess yes, but that's just a guess.
Actually, that should be: reshape(obj, newshape) =>
ascontiguousarray(obj).reshape(newshape)
>
> * This means that "somenoncontiguousarray.reshape(newshape)" will
> oftern raise an error. That's a good thing, but I figured I'd get it
> out in the open now so no one is suprised.
>
> * Since x.reshape would no longer return copies, the order flag is
> unnecessary.
>
> * numpy.reshape(obj, newshape) on the other hand, always copies, so it
> *could* grow an order flag. I think that I'd prefer that it didn't; if
> you need that kind of control of the resulting arrays you should be
> using array to copy your matrices.
>
> * What does fixing ravel to be consistent mean? Always return a view?
> Or always return a copy? The latter seems more useful, as the first is
> already covered by both obj.reshape(-1) and obj.flat.
>
> Regards,
>
> -tim
>
>
>
>
>
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting
> language
> that extends applications into web and mobile media. Attend the live
> webcast
> and join the prime developer group breaking into this new coding
> territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/numpy-discussion
>
>
More information about the Numpy-discussion
mailing list