Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-20 Thread Travis Oliphant
A. M. Archibald wrote: >On 18/10/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: > > > >>If there are any cases satisfying these rules where a copy does not have >>to occur then let me know. >> >> > >For example, zeros((4,4))[:,1].reshape((2,2)) need not be copied. > >I filed a bug in trac an

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-20 Thread A. M. Archibald
On 18/10/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: > If there are any cases satisfying these rules where a copy does not have > to occur then let me know. For example, zeros((4,4))[:,1].reshape((2,2)) need not be copied. I filed a bug in trac and supplied a patch to multiarray.c that avoids

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Charles R Harris
On 10/18/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: Charles R Harris wrote:>>> On 10/18/06, *Travis Oliphant* <[EMAIL PROTECTED]> [EMAIL PROTECTED] >> wrote:>> Charles R Harris wrote:>> > Well, I knew that for numeric, but it was a good deal less> obvious in> > combo with the or

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Travis Oliphant
Charles R Harris wrote: > > > On 10/18/06, *Travis Oliphant* <[EMAIL PROTECTED] > > wrote: > > Charles R Harris wrote: > > > Well, I knew that for numeric, but it was a good deal less > obvious in > > combo with the order keyword. For instance, contiguou

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Charles R Harris
On 10/18/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: Charles R Harris wrote:> Well, I knew that for numeric, but it was a good deal less obvious in> combo with the order keyword.  For instance, contiguous could change> its meaning to match up with FORTRAN, so that FORTRAN=True and > CONTIGUOUS=T

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Travis Oliphant
Charles R Harris wrote: > Well, I knew that for numeric, but it was a good deal less obvious in > combo with the order keyword. For instance, contiguous could change > its meaning to match up with FORTRAN, so that FORTRAN=True and > CONTIGUOUS=True meant Fortran contiguous, which was sort of w

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread George Nurser
On 18/10/06, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > On 10/18/06, George Nurser <[EMAIL PROTECTED]> wrote: > > > > None of the LaPack stuff seems to use the Fortran stuff, they just > > > > transpose and copy. > > > > You've got me worried here. I have assumed that when you start with a >

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Charles R Harris
On 10/18/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: Charles R Harris wrote:>> Could we make a few changes ;)>> For printing the flags I would suggest using C-Contiguous and> F-Contiguous so folks don't have to read the book. And at the c level > define alternates, i.e, #define c-contiguous cont

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Travis Oliphant
Charles R Harris wrote: > > Could we make a few changes ;) > > For printing the flags I would suggest using C-Contiguous and > F-Contiguous so folks don't have to read the book. And at the c level > define alternates, i.e, #define c-contiguous contiguous or whatever. > That way backward compati

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Charles R Harris
On 10/18/06, George Nurser <[EMAIL PROTECTED]> wrote: > > None of the LaPack stuff seems to use the Fortran stuff, they just> > transpose and copy.You've got me worried here. I have assumed that when you start with ac-contiguous array, a, with say, a.shape = (m,n), if you use thetranspose as an arg

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread George Nurser
> > None of the LaPack stuff seems to use the Fortran stuff, they just > > transpose and copy. You've got me worried here. I have assumed that when you start with a c-contiguous array, a, with say,a.shape = (m,n), if you use the transpose as an argument to a fortran routine which requires an mxn s

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Charles R Harris
Travis,On 10/18/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: Tim Hochberg wrote:> One thing that may be confusing the issue is that, as I understand it,> FORTRAN and CONTIGUOUS together represent three states which I'll call> FORTRAN_ORDER, C_ORDER and DISCONTIGUOUS. Yep,  that's what they mean. 

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Travis Oliphant
Tim Hochberg wrote: > One thing that may be confusing the issue is that, as I understand it, > FORTRAN and CONTIGUOUS together represent three states which I'll call > FORTRAN_ORDER, C_ORDER and DISCONTIGUOUS. Yep, that's what they mean. CONTIGUOUS is the name Numeric gave it and it meant C-

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Travis Oliphant
> > I'm not talking about the keyword in the ravel call, I'm talking about > the flag in a. Ah. Yes, I see. I misunderstood. Of course ravel ignores the FORTRAN flag (actually it doesn't because if a copy is not necessary it doesn't make one).The key is that the Python user doesn't need

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Travis Oliphant
> > I'm not talking about the keyword in the ravel call, I'm talking about > the flag in a. Ah. Yes, I see. I misunderstood. Of course ravel ignores the FORTRAN flag (actually it doesn't because if a copy is not necessary it doesn't make one).The key is that the Python user doesn't need

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Charles R Harris
On 10/18/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: Charles R Harris wrote:>>> On 10/18/06, *Tim Hochberg* <[EMAIL PROTECTED]> [EMAIL PROTECTED] >> wrote:>> Charles R Harris wrote:>> [SNIP]> >> > I'm not talking about the keyword in the ravel call, I'm talking> about> > the

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Tim Hochberg
Charles R Harris wrote: > > > On 10/18/06, *Tim Hochberg* <[EMAIL PROTECTED] > > wrote: > > Charles R Harris wrote: > > [SNIP] > > > > I'm not talking about the keyword in the ravel call, I'm talking > about > > the flag in a. The question is: do w

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Charles R Harris
On 10/18/06, Tim Hochberg <[EMAIL PROTECTED]> wrote: Charles R Harris wrote:[SNIP]>> I'm not talking about the keyword in the ravel call, I'm talking about> the flag in a. The question is: do we *need* a fortran flag. I am> argueing not, because the only need is for fortran contiguous arrays > to p

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Tim Hochberg
Charles R Harris wrote: [SNIP] > > I'm not talking about the keyword in the ravel call, I'm talking about > the flag in a. The question is: do we *need* a fortran flag. I am > argueing not, because the only need is for fortran contiguous arrays > to pass to fortran function, or translation from

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Tim Hochberg
One thing that may be confusing the issue is that, as I understand it, FORTRAN and CONTIGUOUS together represent three states which I'll call FORTRAN_ORDER, C_ORDER and DISCONTIGUOUS. I periodically wonder if it would be valuable to have a way to query the order directly: the result would be "

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Charles R Harris
On 10/18/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: >> Currently, the key operation is reshape, which only needs to return a> view in fortran order and doesn't even need to mark the resulting> array as fortran order because, well, because it works just fine in > numpy as is, it just isn't conti

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Travis Oliphant
> > Currently, the key operation is reshape, which only needs to return a > view in fortran order and doesn't even need to mark the resulting > array as fortran order because, well, because it works just fine in > numpy as is, it just isn't contiguous. If the other functions took > shape and o

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Travis Oliphant
Charles R Harris wrote: > > > On 10/17/06, *Charles R Harris* <[EMAIL PROTECTED] > > wrote: > > > > On 10/17/06, *A. M. Archibald* < [EMAIL PROTECTED] > > wrote: > > On 17/10/06, Charles R Harris <[EMAIL PROTECTED] >

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Charles R Harris
On 10/17/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: Stefan van der Walt wrote:> One last case, which confuses me still (probably because it is> 04:16am):Please continue to question.  All the code needs as much review as itcan get. I am really starting to wonder why we need an order keyword at a

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread A. M. Archibald
On 18/10/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: > > I just committed a change to the check-for-copy code to SVN. A copy > will occur if an actual reshaping is taking place that involves more > than just adding or deleting ones from the old shape and if > > 1) self is not "single-segment".

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread A. M. Archibald
On 18/10/06, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > On 10/17/06, A. M. Archibald <[EMAIL PROTECTED]> wrote: > > On 17/10/06, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > > > > > > > On 10/17/06, Travis Oliphant <[EMAIL PROTECTED] > wrote: > > > > > > Thus, reshape does the equivalen

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Charles R Harris
On 10/17/06, A. M. Archibald <[EMAIL PROTECTED]> wrote: On 17/10/06, Charles R Harris <[EMAIL PROTECTED]> wrote:>>> On 10/17/06, Travis Oliphant <[EMAIL PROTECTED] > wrote:> > Thus, reshape does the equivalent of a Fortran ravel to [1,4,2,5,3,6]> > and then a Fortran-order based fill of an empty (3

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread A. M. Archibald
On 17/10/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: Charles R Harris wrote: > > In [3]: array([[1,2,3,4,5,6]]).reshape((3,2),order='F') > Out[3]: > array([[1, 4], >[2, 5], >[3, 6]]) > > I also don't understand why a copy is returned if 'F' just fiddles > with the indices and s

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Charles R Harris
On 10/17/06, Charles R Harris <[EMAIL PROTECTED]> wrote: On 10/17/06, A. M. Archibald < [EMAIL PROTECTED]> wrote: On 17/10/06, Charles R Harris <[EMAIL PROTECTED]> wrote:>>> On 10/17/06, Travis Oliphant < [EMAIL PROTECTED] > wrote: Which doesn't seem to be the case here. I am beginning to wonder i

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Travis Oliphant
> > You are right, it doesn't need to. My check is not general > enough. > > It can be challenging to come up with a general way to > differentiate the > view-vs-copy situation and I struggled with it. In this case, > it's the > fact that

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-18 Thread Travis Oliphant
Stefan van der Walt wrote: > One last case, which confuses me still (probably because it is > 04:16am): > > In [41]: x = N.array([[0,1,2],[3,4,5]],order='F') > > In [42]: x > Out[42]: > array([[0, 1, 2], >[3, 4, 5]]) > > I assume the data is now stored in memory as > > [0 3 1 4 2 5] (colum

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread A. M. Archibald
On 17/10/06, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > On 10/17/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: > > Thus, reshape does the equivalent of a Fortran ravel to [1,4,2,5,3,6] > > and then a Fortran-order based fill of an empty (3,2) array: giving you > > the result. > > Why a Fo

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Charles R Harris
On 10/17/06, Charles R Harris <[EMAIL PROTECTED]> wrote: On 10/17/06, Travis Oliphant < [EMAIL PROTECTED]> wrote: Charles R Harris wrote:>>> On 10/17/06, *Lisandro Dalcin* <[EMAIL PROTECTED]> [EMAIL PROTECTED]>> wrote: >> I was surprised by this>> In [14]: array([[1,2,3],[4,5,6]]).reshape((

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Charles R Harris
On 10/17/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: Charles R Harris wrote:>>> On 10/17/06, *Lisandro Dalcin* <[EMAIL PROTECTED]> [EMAIL PROTECTED]>> wrote: >> I was surprised by this>> In [14]: array([[1,2,3],[4,5,6]]).reshape((3,2),order='F')> Out[14]:> array([[1, 5],>

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Stefan van der Walt
On Tue, Oct 17, 2006 at 07:53:11PM -0600, Travis Oliphant wrote: > Stefan van der Walt wrote: > > Hi all, > > > > Some of you may have seen the interesting thread on Fortran-ordering > > earlier. I thought it might be fun to set up a short quiz which tests > > your knowledge on the topic. > > > >

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Charles R Harris
On 10/17/06, Travis Oliphant <[EMAIL PROTECTED]> wrote: Charles R Harris wrote:>>> On 10/17/06, *Lisandro Dalcin* <[EMAIL PROTECTED]> [EMAIL PROTECTED]>> wrote: >> I was surprised by this>> In [14]: array([[1,2,3],[4,5,6]]).reshape((3,2),order='F')> Out[14]:> array([[1, 5],>

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Travis Oliphant
Charles R Harris wrote: > > > On 10/17/06, *Lisandro Dalcin* <[EMAIL PROTECTED] > > wrote: > > I was surprised by this > > In [14]: array([[1,2,3],[4,5,6]]).reshape((3,2),order='F') > Out[14]: > array([[1, 5], >[4, 3], >[2, 6]]) > >

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Travis Oliphant
Charles R Harris wrote: > > > On 10/17/06, *Lisandro Dalcin* <[EMAIL PROTECTED] > > wrote: > > I was surprised by this > > In [14]: array([[1,2,3],[4,5,6]]).reshape((3,2),order='F') > Out[14]: > array([[1, 5], >[4, 3], >[2, 6]]) > >

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Travis Oliphant
Stefan van der Walt wrote: > Hi all, > > Some of you may have seen the interesting thread on Fortran-ordering > earlier. I thought it might be fun to set up a short quiz which tests > your knowledge on the topic. > > If you're up for the challenge, take a look at > > http://mentat.za.net/numpy/qui

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Charles R Harris
On 10/17/06, Lisandro Dalcin <[EMAIL PROTECTED]> wrote: I was surprised by thisIn [14]: array([[1,2,3],[4,5,6]]).reshape((3,2),order='F')Out[14]:array([[1, 5],   [4, 3],   [2, 6]])This one still looks wrong. In [15]: array([1,2,3,4,5,6]).reshape((3,2),order='F')Out[15]:array([[1, 2],  

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Stefan van der Walt
On Wed, Oct 18, 2006 at 10:30:26AM +0900, Bill Baxter wrote: > I think the answer to #3 is wrong. > > >From 1.0rc2 I get: > >>> array([1,2,3,4,5,6],order='C').reshape((2,3),order='F') > array([[1, 2, 3], >[4, 5, 6]]) > > But the quiz wants me to answer something different. This recently

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Travis Oliphant
Lisandro Dalcin wrote: > I was surprised by this > > In [14]: array([[1,2,3],[4,5,6]]).reshape((3,2),order='F') > Out[14]: > array([[1, 5], >[4, 3], >[2, 6]]) > > In [15]: array([1,2,3,4,5,6]).reshape((3,2),order='F') > Out[15]: > array([[1, 2], >[3, 4], >[5, 6]]) >

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Bill Baxter
I think the answer to #3 is wrong. >From 1.0rc2 I get: >>> array([1,2,3,4,5,6],order='C').reshape((2,3),order='F') array([[1, 2, 3], [4, 5, 6]]) But the quiz wants me to answer something different. --bb - Using Tomca

Re: [Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Lisandro Dalcin
I was surprised by this In [14]: array([[1,2,3],[4,5,6]]).reshape((3,2),order='F') Out[14]: array([[1, 5], [4, 3], [2, 6]]) In [15]: array([1,2,3,4,5,6]).reshape((3,2),order='F') Out[15]: array([[1, 2], [3, 4], [5, 6]]) On 10/17/06, Stefan van der Walt <[EMAIL PROTEC

[Numpy-discussion] The NumPy Fortran-ordering quiz

2006-10-17 Thread Stefan van der Walt
Hi all, Some of you may have seen the interesting thread on Fortran-ordering earlier. I thought it might be fun to set up a short quiz which tests your knowledge on the topic. If you're up for the challenge, take a look at http://mentat.za.net/numpy/quiz I won't be held liable for any emotiona