[Numpy-discussion] Ransom Proposals

Charles R Harris charlesr.harris at gmail.com
Tue Mar 28 13:24:04 CST 2006


On 3/28/06, Travis Oliphant <oliphant.travis at ieee.org> wrote:
> Tim Hochberg wrote:


a = rand(4,5,3)
> b = a.transpose().reshape(15,4)
> c = a.reshape(15,4)

I would do this:

>> b = reshape(a.transpose(), (15,4))

or, if the functional version of transpose would always return a copy:

>> b = transpose(a).reshape(15,4)

As I said before, I simply stopped using reshape because of its ambiguous
behaviour. There were clearer ways to get what I wanted. But in any case,
the casual user will hardly notice the inefficiency of making a copy. Users
concerned with speed can use methods and should know enough to understand
what is going on, but they should be warned if their attemps at efficiency
aren't going to pan out in a particular case.

> My argument is that the reshape method documentation should state that
> you should not modify the contents of the return value of reshape unless
> it doesn't matter whether or not you have a copy of the data.

Who reads documentation? Why should they have to rummage through the
footnotes or run a bunch of test cases to discover why things aren't

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/numpy-discussion/attachments/20060328/8f80e3ea/attachment-0001.html 

More information about the Numpy-discussion mailing list