Re: [Numpy-discussion] preferred way of testing empty arrays

2012-01-30 Thread Chris Barker
On Fri, Jan 27, 2012 at 1:29 PM, Robert Kern wrote: > Well, if you really need to do this in more than one place, define a > utility function and call it a day. > > def should_not_plot(x): >    if x is None: >        return True >    elif isinstance(x, np.ndarray): >        return x.size == 0 >  

Re: [Numpy-discussion] histogram help

2012-01-30 Thread Samuel John
Hi Ruby, I still do not fully understand your question but what I do in such cases is to construct a very simple array and test the functions. The help of numpy.histogram2d or numpy.histogramdd (for more than two dims) might help here. So I guess, basically you want to ignore the x,y positions

Re: [Numpy-discussion] histogram help

2012-01-30 Thread Ruby Stevenson
Sorry, I realize I didn't describe the problem completely clear or correct. the (x,y) in this case is just many co-ordinates, and each coordinate has a list of values (Z value) associated with it. The bins are allocated for the Z. I hope this clarify things a little. Thanks again. Ruby On

Re: [Numpy-discussion] condense array along one dimension

2012-01-30 Thread Ruby Stevenson
I think this is exactly what I need. Thanks for your help, Olivier. Ruby On Fri, Jan 20, 2012 at 9:50 AM, Olivier Delalleau wrote: > What do you mean by "summarize"? > If for instance you want to sum along Y, just do >   my_array.sum(axis=1) > > -=- Olivier > > 2012/1/20 Ruby Stevenson >> >> hi

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Ted To
> You'd want to update your mask appropriately to get everything you > want to select, one criteria at a time e.g.: > mask = a[:,0] == 1 > mask &= a[:,1] == 1960 > > Alternatively: > mask = (a[:,0] == 1) & (a[:,1] == 1960) > but be careful with the parens, & and | are normally high-priority > bitw

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Brett Olsen
On Mon, Jan 30, 2012 at 11:31 AM, Ted To wrote: > On 01/30/2012 12:13 PM, Brett Olsen wrote: >> On Mon, Jan 30, 2012 at 10:57 AM, Ted To wrote: >>> Sure thing.  To keep it simple suppose I have just a two dimensional >>> array (time,output): >>> [(1,2),(2,3),(3,4)] >>> I would like to look at all

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Zachary Pincus
> Thanks! That works great if I only want to search over one index but I > can't quite figure out what to do with more than a single index. So > suppose I have a labeled, multidimensional array with labels 'month', > 'year' and 'quantity'. a[['month','year']] gives me an array of indices > but "

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Ted To
On 01/30/2012 12:13 PM, Brett Olsen wrote: > On Mon, Jan 30, 2012 at 10:57 AM, Ted To wrote: >> Sure thing. To keep it simple suppose I have just a two dimensional >> array (time,output): >> [(1,2),(2,3),(3,4)] >> I would like to look at all values of output for which, for example time==2. >> >>

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Brett Olsen
On Mon, Jan 30, 2012 at 10:57 AM, Ted To wrote: > Sure thing.  To keep it simple suppose I have just a two dimensional > array (time,output): > [(1,2),(2,3),(3,4)] > I would like to look at all values of output for which, for example time==2. > > My actual application has a six dimensional array a

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Ted To
Sure thing. To keep it simple suppose I have just a two dimensional array (time,output): [(1,2),(2,3),(3,4)] I would like to look at all values of output for which, for example time==2. My actual application has a six dimensional array and I'd like to look at the contents using one or more of the

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Zachary Pincus
Ted, can you clarify what you're asking for? Maybe give a trivial example of an array and the desired output? I'm pretty sure this is a slicing question though: > If I have a three dimensional array a=(x,y,z), can I look at the values of z > given particular values for x and y? Given that elemen

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Chao YUE
he is not asking for slicing. he is asking for how to index array by element value but not element index. 2012/1/30 Zachary Pincus > a[x,y,:] > > Read the slicing part of the tutorial: > http://www.scipy.org/Tentative_NumPy_Tutorial > (section 1.6) > > And the documentation: > http://docs.scipy.

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Zachary Pincus
a[x,y,:] Read the slicing part of the tutorial: http://www.scipy.org/Tentative_NumPy_Tutorial (section 1.6) And the documentation: http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html On Jan 30, 2012, at 10:25 AM, Ted To wrote: > Hi, > > Is there some straightforward way to access

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Malcolm Reynolds
On Mon, Jan 30, 2012 at 3:25 PM, Ted To wrote: > Is there some straightforward way to access an array by values across a > subset of its dimensions?  For example, if I have a three dimensional > array a=(x,y,z), can I look at the values of z given particular values > for x and y? a[x, y, :] shoul

Re: [Numpy-discussion] Addressing arrays

2012-01-30 Thread Chao YUE
I am afraid you have to write index inquire function by yourself. I did like this. chao 2012/1/30 Ted To > Hi, > > Is there some straightforward way to access an array by values across a > subset of its dimensions? For example, if I have a three dimensional > array a=(x,y,z), can I look at the

[Numpy-discussion] Addressing arrays

2012-01-30 Thread Ted To
Hi, Is there some straightforward way to access an array by values across a subset of its dimensions? For example, if I have a three dimensional array a=(x,y,z), can I look at the values of z given particular values for x and y? Thanks, Ted ___ NumPy-D

Re: [Numpy-discussion] Unrealistic expectations of class Polynomial or a bug?

2012-01-30 Thread eat
On Sat, Jan 28, 2012 at 11:14 PM, Charles R Harris < charlesr.har...@gmail.com> wrote: > > > On Sat, Jan 28, 2012 at 11:15 AM, eat wrote: > >> Hi, >> >> Short demonstration of the issue: >> In []: sys.version >> Out[]: '2.7.2 (default, Jun 12 2011, 15:08:59) [MSC v.1500 32 bit >> (Intel)]' >> In