Re: [Numpy-discussion] Detect if array has been transposed

2014-10-13 Thread Mads Ipsen
On 13/10/14 01:18, Nathaniel Smith wrote: > On Mon, Oct 13, 2014 at 12:07 AM, Pauli Virtanen wrote: >> 12.10.2014, 22:16, Eric Firing kirjoitti: >>> On 2014/10/12, 8:29 AM, Pauli Virtanen wrote: 12.10.2014, 20:19, Mads Ipsen kirjoitti: > Is there any way for me to detect (on the Python si

Re: [Numpy-discussion] Detect if array has been transposed

2014-10-12 Thread Nathaniel Smith
On Mon, Oct 13, 2014 at 12:07 AM, Pauli Virtanen wrote: > 12.10.2014, 22:16, Eric Firing kirjoitti: >> On 2014/10/12, 8:29 AM, Pauli Virtanen wrote: >>> 12.10.2014, 20:19, Mads Ipsen kirjoitti: Is there any way for me to detect (on the Python side) that transpose() has been invoked on th

Re: [Numpy-discussion] Detect if array has been transposed

2014-10-12 Thread Pauli Virtanen
12.10.2014, 22:16, Eric Firing kirjoitti: > On 2014/10/12, 8:29 AM, Pauli Virtanen wrote: >> 12.10.2014, 20:19, Mads Ipsen kirjoitti: >>> Is there any way for me to detect (on the Python side) that transpose() >>> has been invoked on the matrix, and thereby only do the copy operation >>> when it re

Re: [Numpy-discussion] Detect if array has been transposed

2014-10-12 Thread Eric Firing
On 2014/10/12, 8:29 AM, Pauli Virtanen wrote: > 12.10.2014, 20:19, Mads Ipsen kirjoitti: >> Is there any way for me to detect (on the Python side) that transpose() >> has been invoked on the matrix, and thereby only do the copy operation >> when it really is needed? > > The correct way to do this i

Re: [Numpy-discussion] Detect if array has been transposed

2014-10-12 Thread Pauli Virtanen
12.10.2014, 20:19, Mads Ipsen kirjoitti: > Is there any way for me to detect (on the Python side) that transpose() > has been invoked on the matrix, and thereby only do the copy operation > when it really is needed? The correct way to do this is to, either: In your C code check PyArray_IS_C_CO

[Numpy-discussion] Detect if array has been transposed

2014-10-12 Thread Mads Ipsen
Hi, In part of my C++ code, I often do void foo(PyObject * matrix) { do stuff } where matrix is a numpy mxn matrix created on the Python side, where foo() eg. is invoked as a = numpy.array([[1,2],[3,5]]) foo(a) However, if you call transpose() on a, some care should be taken, since numpy'