Re: [Numpy-discussion] Unexpected behavior with numpy array

2008-02-03 Thread Robert Kern
Travis E. Oliphant wrote: > Damian Eads wrote: >> This is good to know because there have been a few situations when this >> would have been very useful. >> >> Suppose I do something like (in Python): >> >>import ctypes >>mylib = ctypes.CDLL('libmylib.so') >>y = mylib.get_float_array_f

Re: [Numpy-discussion] Unexpected behavior with numpy array

2008-02-03 Thread Travis E. Oliphant
Damian Eads wrote: > > This is good to know because there have been a few situations when this > would have been very useful. > > Suppose I do something like (in Python): > >import ctypes >mylib = ctypes.CDLL('libmylib.so') >y = mylib.get_float_array_from_c_function() > > which returns

Re: [Numpy-discussion] Unexpected behavior with numpy array

2008-02-03 Thread Robert Kern
Damian Eads wrote: > Robert Kern wrote: >> Damian Eads wrote: >>> Here's another question: is there any way to construct a numpy array and >>> specify the buffer address where it should store its values? I ask >>> because I would like to construct numpy arrays that work on buffers that >>> come

Re: [Numpy-discussion] Unexpected behavior with numpy array

2008-02-03 Thread Damian Eads
Robert Kern wrote: > Damian Eads wrote: >> Here's another question: is there any way to construct a numpy array and >> specify the buffer address where it should store its values? I ask >> because I would like to construct numpy arrays that work on buffers that >> come from mmap. > > Can you cl

Re: [Numpy-discussion] Unexpected behavior with numpy array

2008-02-03 Thread Robert Kern
Damian Eads wrote: > Here's another question: is there any way to construct a numpy array and > specify the buffer address where it should store its values? I ask > because I would like to construct numpy arrays that work on buffers that > come from mmap. Can you clarify that a little? By "buff

Re: [Numpy-discussion] Unexpected behavior with numpy array

2008-02-03 Thread Damian Eads
Thanks Anne for your very informative response. Anne Archibald wrote: > On 03/02/2008, Damian Eads <[EMAIL PROTECTED]> wrote: >> Good day, >> >> Reversing a 1-dimensional array in numpy is simple, >> >> A = A[:,:,-1] . >> >> However A is a new array referring to the old one and is no longe

Re: [Numpy-discussion] Unexpected behavior with numpy array

2008-02-03 Thread Anne Archibald
On 03/02/2008, Damian Eads <[EMAIL PROTECTED]> wrote: > Good day, > > Reversing a 1-dimensional array in numpy is simple, > > A = A[:,:,-1] . > > However A is a new array referring to the old one and is no longer > contiguous. > > While trying to reverse an array in place and keep it contig

Re: [Numpy-discussion] Unexpected behavior with numpy array

2008-02-03 Thread Gael Varoquaux
On Sun, Feb 03, 2008 at 12:25:56PM -0700, Damian Eads wrote: > On similar note, does the assignment >A = A * B > create a new array with a new buffer to hold the result of A * B, and > assign A to refer to the new array? Yes. Without a JIT, Python cannot know that A is present both on t

Re: [Numpy-discussion] Unexpected behavior with numpy array

2008-02-03 Thread Damian Eads
Damian Eads wrote: > Good day, > > Reversing a 1-dimensional array in numpy is simple, > > A = A[:,:,-1] . Err, I meant A=A[::-1] here. My apologies. ___ Numpy-discussion mailing list Numpy-discussion@scipy.org http://projects.scipy.org/mailman

[Numpy-discussion] Unexpected behavior with numpy array

2008-02-03 Thread Damian Eads
Good day, Reversing a 1-dimensional array in numpy is simple, A = A[:,:,-1] . However A is a new array referring to the old one and is no longer contiguous. While trying to reverse an array in place and keep it contiguous, I encountered some weird behavior. The reason for keeping it c