Re: [Numpy-discussion] Recarray comparison and byte order

2009-10-31 Thread Matthew Brett
Hi, >> c = a.byteswap().newbyteorder() >> c == a > > In the last two lines, a variable "c" is assigned to a modified "a".  The > next line tests (==) to see if "c" is the same as (==) the unmodified "a". > It isn't, because "c" is the modified "a".  Hence, "False". Sorry, I wasn't very clear - th

Re: [Numpy-discussion] Recarray comparison and byte order

2009-10-31 Thread Ian Mallett
On Sat, Oct 31, 2009 at 9:38 AM, Matthew Brett wrote: > c = a.byteswap().newbyteorder() > c == a > In the last two lines, a variable "c" is assigned to a modified "a". The next line tests (==) to see if "c" is the same as (==) the unmodified "a". It isn't, because "c" is the modified "a". Hence,

[Numpy-discussion] Recarray comparison and byte order

2009-10-31 Thread Matthew Brett
Hi, I was surprised by this - is it a bug or a feature or me misunderstanding something? a = np.zeros((1,), dtype=[('f1', 'u2')]) b = a.copy() b == a (array([True], dtype=bool)) # as expected c = a.byteswap().newbyteorder() c == a (False) # to me, unexpected, note bool rather than array Thanks f

Re: [Numpy-discussion] just how 'discontiguous' can a numpy array become?

2009-10-31 Thread Chris Colbert
Great! Thanks for the help David! On Sat, Oct 31, 2009 at 1:58 PM, David Cournapeau wrote: > On Sat, Oct 31, 2009 at 9:45 PM, Chris Colbert wrote: > >> Graphically can this every occur in hardware memory: >> >> |--- a portion of array A ---|--- python object foo ---|--- The rest >> of array A

Re: [Numpy-discussion] just how 'discontiguous' can a numpy array become?

2009-10-31 Thread David Cournapeau
On Sat, Oct 31, 2009 at 9:45 PM, Chris Colbert wrote: > Graphically can this every occur in hardware memory: > > |--- a portion of array A ---|--- python object foo ---|--- The rest > of array A | No, this can never happen in the current numpy memory model, the allocated block has to be cont

Re: [Numpy-discussion] just how 'discontiguous' can a numpy array become?

2009-10-31 Thread Chris Colbert
Thanks for the response david. Lemme rephrase the question a little bit. It terms of actually memory space, will a numpy array ever point to a chunk of memory that is not a continually running series of memory addresses and also not a child of a continuous block of addresses. Graphically can th

Re: [Numpy-discussion] just how 'discontiguous' can a numpy array become?

2009-10-31 Thread David Cournapeau
On Sat, Oct 31, 2009 at 9:22 PM, Chris Colbert wrote: > > Will there ever be a situation where a discontiguous array owns its > own data? Or more generally, will discontiguous data alway have a > contiguous parent? Yes to Q1 and No to Q2. Discontiguous arrays are very easy to create: for exampl

[Numpy-discussion] just how 'discontiguous' can a numpy array become?

2009-10-31 Thread Chris Colbert
For example say we have an original array a=np.random.random((512, 512, 3)) and we take a slice of that array b=a[:100, :100, :] now, b is discontiguous, but all if its memory is owned by a. Will there ever be a situation where a discontiguous array owns its own data? Or more generally, will dis