Re: [Numpy-discussion] Fancy Indexing of Structured Arrays is Slow

2014-05-21 Thread Dave Hirschfeld
Julian Taylor googlemail.com> writes: > > On 16.05.2014 10:59, Dave Hirschfeld wrote: > > Julian Taylor googlemail.com> writes: > > > > Yes, I'd heard about the improvements and am very excited to try them out > > since indexing is one of the bottlenecks in our algorithm. > > > > I made a

[Numpy-discussion] Easter Egg or what I am missing here?

2014-05-21 Thread Siegfried Gonzi
Please would anyone tell me the following is an undocumented bug otherwise I will lose faith in everything: == import numpy as np years = [2004,2005,2006,2007] dates = [20040501,20050601,20060801,20071001] for x in years: print 'year ',x xy = np.array([x*1.0e-4 for x in dates]).a

Re: [Numpy-discussion] Easter Egg or what I am missing here?

2014-05-21 Thread alex
On Wed, May 21, 2014 at 3:29 PM, Siegfried Gonzi wrote: > Please would anyone tell me the following is an undocumented bug > otherwise I will lose faith in everything: > > == > import numpy as np > > > years = [2004,2005,2006,2007] > > dates = [20040501,20050601,20060801,20071001] > > for x in yea

Re: [Numpy-discussion] Easter Egg or what I am missing here?

2014-05-21 Thread Chris Barker
On Wed, May 21, 2014 at 12:38 PM, alex wrote: > > years = [2004,2005,2006,2007] > > > > dates = [20040501,20050601,20060801,20071001] > > > > for x in years: > > > > print 'year ',x > > > > xy = np.array([x*1.0e-4 for x in dates]).astype(np.int) > > > > print 'year ',x > did you

Re: [Numpy-discussion] Easter Egg or what I am missing here?

2014-05-21 Thread Warren Weckesser
On 5/21/14, Siegfried Gonzi wrote: > Please would anyone tell me the following is an undocumented bug > otherwise I will lose faith in everything: > > == > import numpy as np > > > years = [2004,2005,2006,2007] > > dates = [20040501,20050601,20060801,20071001] > > for x in years: > > print 'y

[Numpy-discussion] NumPy C API question

2014-05-21 Thread Stefan Seefeld
Hello, I would like to expose an existing (C++) object as a NumPy array to Python. Right now I'm using PyArray_New, passing the pointer to my object's storage. It now happens that the storage point of my object may change over its lifetime, so I'd like to change the pointer that is used in the PyA

Re: [Numpy-discussion] NumPy C API question

2014-05-21 Thread Nathaniel Smith
Hi Stefan, Allocating a new PyArrayObject isn't terribly expensive (compared to all the other allocations that Python programs are constantly doing), but I'm afraid you have a more fundamental problem. The reason there is no supported API to change the storage pointer of a PyArrayObject is that th

Re: [Numpy-discussion] NumPy C API question

2014-05-21 Thread Stefan Seefeld
Hi Nathaniel, thanks for the prompt and thorough answer. You are entirely right, I hadn't thought things through properly, so let me back up a bit. I want to provide Python bindings to a C++ library I'm writing, which is based on vector/matrix/tensor data types. In my naive view I would expose th

Re: [Numpy-discussion] NumPy C API question

2014-05-21 Thread Nathaniel Smith
Hi Stefan, One possibility that comes to mind: you may want in any case some way to temporarily "pin" an object's memory in place (e.g., to prevent one thread trying to migrate it while some other thread is working on it). If so then the Python wrapper could acquire a pin when the ndarray is alloc

[Numpy-discussion] Find Daily max - create lists using date and add hourly data to that list for the day

2014-05-21 Thread questions anon
I have hourly 2D temperature data in a monthly netcdf and I would like to find the daily maximum temperature. The shape of the netcdf is (744, 106, 193) I would like to use the year-month-day as a new list name (i.e. 2009-03-01, 2009-03-022009-03-31) and then add each of the hours worth of tem

Re: [Numpy-discussion] Find Daily max - create lists using date and add hourly data to that list for the day

2014-05-21 Thread Stephan Hoyer
Hello anonymous, I recently wrote a package "xray" (http://xray.readthedocs.org/) specifically to make it easier to work with high-dimensional labeled data, as often found in NetCDF files. Xray has a groupby method for grouping over subsets of your data, which would seem well suited to what you're

Re: [Numpy-discussion] Find Daily max - create lists using date and add hourly data to that list for the day

2014-05-21 Thread questions anon
Thanks Stephan, It doesn't look like CDAT has 'daily' option - it has yearly, seasonal and monthly! I would need to look into IRIS more as it is new to me and I can't quiet figure out all the steps required for xray, although it looks great. Another way around was after converting to localtime_day

Re: [Numpy-discussion] Easter Egg or what I am missing here?

2014-05-21 Thread Siegfried Gonzi
On 22/05/2014 00:37, numpy-discussion-requ...@scipy.org wrote: > Message: 4 Date: Wed, 21 May 2014 18:32:30 -0400 From: Warren > Weckesser Subject: Re: [Numpy-discussion] > Easter Egg or what I am missing here? To: Discussion of Numerical > Python Message-ID: > > Content-Type: text/plain; c

Re: [Numpy-discussion] Easter Egg or what I am missing here?

2014-05-21 Thread Eelco Hoogendoorn
I agree; this 'wart' has also messed with my code a few times. I didn't find it to be the case two years ago, but perhaps I should reevaluate if the scientific python stack has sufficiently migrated to python 3. On Thu, May 22, 2014 at 7:35 AM, Siegfried Gonzi wrote: > On 22/05/2014 00:37, numpy