Re: [Numpy-discussion] how to store variable length string in array and get single char by it's position?

2010-09-14 Thread Keith Goodman
On Tue, Sep 14, 2010 at 9:25 AM, kee chen keekychen.sha...@gmail.com wrote: Dear All, Suppose I have a list group some kind like DNA sequence: 1  ATGCATGCAATTGGCC 2  ATGCATGCAATTGGCCATCD 3  CATGCAATTGGC .. 10 CATGCAAATTGGC the string length of each item is not

Re: [Numpy-discussion] dot() performance depends on data?

2010-09-10 Thread Keith Goodman
On Fri, Sep 10, 2010 at 10:36 AM, Hagen Fürstenau ha...@zhuliguan.net wrote: I'm multiplying two 1000x1000 arrays with numpy.dot() and seeing significant performance differences depending on the data. It seems to take much longer on matrices with many zeros than on random ones. I don't know

Re: [Numpy-discussion] weighted mean; weighted standard error of the mean (sem)

2010-09-09 Thread Keith Goodman
On Thu, Sep 9, 2010 at 7:22 PM, cpblpublic cpblpublic+nu...@gmail.com wrote: I am looking for some reaally basic statistical tools. I have some sample data, some sample weights for those measurements, and I want to calculate a mean and a standard error of the mean. How about using a bootstrap?

Re: [Numpy-discussion] weighted mean; weighted standard error of the mean (sem)

2010-09-09 Thread Keith Goodman
On Thu, Sep 9, 2010 at 8:07 PM, Keith Goodman kwgood...@gmail.com wrote: On Thu, Sep 9, 2010 at 7:22 PM, cpblpublic cpblpublic+nu...@gmail.com wrote: I am looking for some reaally basic statistical tools. I have some sample data, some sample weights for those measurements, and I want

Re: [Numpy-discussion] weighted mean; weighted standard error of the mean (sem)

2010-09-09 Thread Keith Goodman
On Thu, Sep 9, 2010 at 8:44 PM, josef.p...@gmail.com wrote: On Thu, Sep 9, 2010 at 11:32 PM, Keith Goodman kwgood...@gmail.com wrote: On Thu, Sep 9, 2010 at 8:07 PM, Keith Goodman kwgood...@gmail.com wrote: On Thu, Sep 9, 2010 at 7:22 PM, cpblpublic cpblpublic+nu...@gmail.com wrote: I am

Re: [Numpy-discussion] Cutoff small values of a vector to stop underflow

2010-09-03 Thread Keith Goodman
On Fri, Sep 3, 2010 at 9:39 AM, Rick Muller rpmul...@gmail.com wrote: There just *has* to be a better way of doing this. I want to cut off small values of a vector, and I'm currently doing something like: for i in xrange(n):     if abs(A[i]) tol: A[i] = 0 Which is slow, since A can be

Re: [Numpy-discussion] comparison between arrays of strings and numerical types

2010-08-31 Thread Keith Goodman
2010/8/31 Ernest Adrogué eadro...@gmx.net: Hi, I find this a bit odd: In [18]: np.array(['a','b','c','d']) 'a' Out[18]: array([False,  True,  True,  True], dtype=bool) In [19]: np.array(['a','b','c','d']) 4 Out[19]: True In [20]: np.array(['a','b','c','d']) 4.5 Out[20]: True Is

Re: [Numpy-discussion] Datarray sprint July 28, 2010

2010-08-23 Thread Keith Goodman
On Mon, Aug 23, 2010 at 2:17 PM, Skipper Seabold jsseab...@gmail.com wrote: Is Fernando's github still the most up to date location for datarray? Yes. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org

Re: [Numpy-discussion] DataArray usage question + bug?

2010-08-23 Thread Keith Goodman
On Mon, Aug 23, 2010 at 3:28 PM, Skipper Seabold jsseab...@gmail.com wrote: hhold_ax = 'households', np.unique(ddd[:,0]).tolist() snip As for the bug report.  If I don't tolist() the ticks above there is an error.  I can file a bug report if it's warranted. If you add it to the tracker

Re: [Numpy-discussion] loading database data into numpy arrays

2010-08-19 Thread Keith Goodman
On Thu, Aug 19, 2010 at 10:00 AM, John Salvatier jsalv...@u.washington.edu wrote: Hello, I am trying to load some time series data into numpy arrays from a MySQL database using pyodbc, but I am not sure what the standard way to do this is. I found the following:

Re: [Numpy-discussion] use index array of len n to select columns of n x m array

2010-08-06 Thread Keith Goodman
On Fri, Aug 6, 2010 at 3:01 AM, Martin Spacek nu...@mspacek.mm.st wrote: Keith Goodman wrote:   Here's one way:     a.flat[i + a.shape[1] * np.arange(a.shape[0])]       array([0, 3, 5, 6, 9]) I'm afraid I made my example a little too simple. In retrospect, what I really want is to be able

Re: [Numpy-discussion] use index array of len n to select columns of n x m array

2010-08-05 Thread Keith Goodman
On Thu, Aug 5, 2010 at 10:12 AM, Martin Spacek nu...@mspacek.mm.st wrote: I want to take an n x m array a and index into it using an integer index array i of length n that will pull out the value at the designated column from each corresponding row of a. a = np.arange(10) a.shape = 5, 2

Re: [Numpy-discussion] use index array of len n to select columns of n x m array

2010-08-05 Thread Keith Goodman
On Thu, Aug 5, 2010 at 10:26 AM, josef.p...@gmail.com wrote: On Thu, Aug 5, 2010 at 1:12 PM, Martin Spacek nu...@mspacek.mm.st wrote: I want to take an n x m array a and index into it using an integer index array i of length n that will pull out the value at the designated column from each

Re: [Numpy-discussion] use index array of len n to select columns of n x m array

2010-08-05 Thread Keith Goodman
On Thu, Aug 5, 2010 at 1:32 PM, josef.p...@gmail.com wrote: On Thu, Aug 5, 2010 at 4:07 PM, Martin Spacek nu...@mspacek.mm.st wrote: josef.pkt wrote: a = np.array([[0, 1],                   [2, 3],                   [4, 5],                   [6, 7],                   [8, 9]]) i =

Re: [Numpy-discussion] Datarray sprint July 28, 2010

2010-07-29 Thread Keith Goodman
On Tue, Jul 27, 2010 at 11:13 AM, Keith Goodman kwgood...@gmail.com wrote: Join us for a datarray sprint on July 28. Several of us will meet at UC Berkeley from 2pm (Pacific Time) until our fingers bleed from typing or until 6 or 7pm, whichever comes first. If you can't be there in person

Re: [Numpy-discussion] str == int puzzlement

2010-07-29 Thread Keith Goodman
On Wed, Jul 28, 2010 at 6:42 PM, Matthew Brett matthew.br...@gmail.com wrote: Hi, Please forgive me if this is obvious, but this surprised me: In [15]: x = np.array(['a', 'b']) In [16]: x == 'a'  # this was what I expected Out[16]: array([ True, False], dtype=bool) In [17]: x == 1 # this

Re: [Numpy-discussion] Problem with importing numpy in Ubuntu

2010-07-27 Thread Keith Goodman
On Tue, Jul 27, 2010 at 9:29 AM, Robert Faryabi robert.fary...@gmail.com wrote: I just looked at my system more carefully. There are two executable files /usr/local/bin/python and /usr/bin/python this is a link to python2.6 I believe that the first one is source compiled version. So,

[Numpy-discussion] Datarray sprint July 28, 2010

2010-07-27 Thread Keith Goodman
Join us for a datarray sprint on July 28. Several of us will meet at UC Berkeley from 2pm (Pacific Time) until our fingers bleed from typing or until 6 or 7pm, whichever comes first. If you can't be there in person, grab an item from the issue tracker or create your own. I'm told some of us will

Re: [Numpy-discussion] Numpy installation problem

2010-07-24 Thread Keith Goodman
On Sat, Jul 24, 2010 at 3:12 PM, Jonathan Tu j...@princeton.edu wrote: On Jul 24, 2010, at 6:09 PM, David Cournapeau wrote: On Sun, Jul 25, 2010 at 7:00 AM, Jonathan Tu j...@princeton.edu wrote: If you install shared libraries into a directory which is not looked in by default by ld, you

Re: [Numpy-discussion] Numpy installation problem

2010-07-24 Thread Keith Goodman
On Sat, Jul 24, 2010 at 3:39 PM, Jonathan Tu j...@princeton.edu wrote: On Jul 24, 2010, at 6:21 PM, David Cournapeau wrote: On Sun, Jul 25, 2010 at 7:12 AM, Jonathan Tu j...@princeton.edu wrote: What does that part do?  It turns out that by fixing my library path, numpy now imports.  I

[Numpy-discussion] Datarray bug tracker

2010-07-23 Thread Keith Goodman
Report datarray bugs here: http://github.com/fperez/datarray/issues A datarray is a subclass of a Numpy array that adds the ability to label the axes and to label the elements along each axis. ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org

Re: [Numpy-discussion] summarizing blocks of an array using a moving window

2010-07-22 Thread Keith Goodman
On Thu, Jul 22, 2010 at 7:48 AM, Warren Weckesser warren.weckes...@enthought.com wrote: Actually, because of the use of reshape(3,3,4), your second example does make a copy. When does reshape return a view and when does it return a copy? Here's a simple example that returns a view: x =

Re: [Numpy-discussion] summarizing blocks of an array using a moving window

2010-07-22 Thread Keith Goodman
On Thu, Jul 22, 2010 at 10:35 AM, Warren Weckesser warren.weckes...@enthought.com wrote: Keith Goodman wrote: On Thu, Jul 22, 2010 at 7:48 AM, Warren Weckesser warren.weckes...@enthought.com wrote: Actually, because of the use of reshape(3,3,4), your second example does make a copy. When

[Numpy-discussion] Datarray BoF, part2

2010-07-21 Thread Keith Goodman
About a dozen people attended what was billed as a continuation of the SciPy 2010 datarray BoF. We met at UC Berkeley on July 19 as part of the py4science series. A datarray is a subclass of a Numpy array that adds the ability to label the axes and to label the elements along each axis. We spent

Re: [Numpy-discussion] Datarray BoF, part2

2010-07-21 Thread Keith Goodman
On Wed, Jul 21, 2010 at 10:58 AM, M Trumpis mtrum...@berkeley.edu wrote: Separately, regarding the permissible axis labels, I think we must not allow any enumerated axis labels (ie, ints and floats). I don't remember if there was a consensus about that yesterday. We don't have the flexibility

Re: [Numpy-discussion] Datarray BoF, part2

2010-07-21 Thread Keith Goodman
On Wed, Jul 21, 2010 at 11:41 AM, Vincent Davis vinc...@vincentdavis.net wrote: On Wed, Jul 21, 2010 at 11:08 AM, Keith Goodman kwgood...@gmail.com wrote: On Wed, Jul 21, 2010 at 9:56 AM, John Salvatier jsalv...@u.washington.edu wrote: I don't really know much about this topic, but what about

Re: [Numpy-discussion] Datarray BoF, part2

2010-07-21 Thread Keith Goodman
On Wed, Jul 21, 2010 at 2:32 PM, Rob Speer rsp...@mit.edu wrote: I agree with the idea that axis labels must be strings. Yes, this is the opposite of my position on tick labels (names), but there's a reason: ticks are often defined by whatever data you happen to be working with, but axis

Re: [Numpy-discussion] lstsq functionality

2010-07-21 Thread Keith Goodman
On Wed, Jul 21, 2010 at 8:24 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Wed, Jul 21, 2010 at 5:44 PM, Keith Goodman kwgood...@gmail.com wrote: Can someone confirm that the copy in np.linalg.lstsq bstar[:b.shape[0],:n_rhs] = b.copy() is not needed? I'm assuming that ndarray

Re: [Numpy-discussion] Stacking arrays along new dimension in front

2010-07-20 Thread Keith Goodman
On Tue, Jul 20, 2010 at 7:24 AM, Skipper Seabold jsseab...@gmail.com wrote: On Tue, Jul 20, 2010 at 5:11 AM, Gael Varoquaux gael.varoqu...@normalesup.org wrote: Is there in numpy a function that does:    np.concatenate([a_[np.newaxis] for a_ in a]) ? ie: add a dimension in front and stack

Re: [Numpy-discussion] lstsq functionality

2010-07-20 Thread Keith Goodman
On Mon, Jul 19, 2010 at 10:08 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Jul 19, 2010 at 9:40 PM, Keith Goodman kwgood...@gmail.com wrote: On Mon, Jul 19, 2010 at 8:27 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Jul 19, 2010 at 9:02 PM, Keith

Re: [Numpy-discussion] lstsq functionality

2010-07-20 Thread Keith Goodman
On Tue, Jul 20, 2010 at 6:35 PM, Keith Goodman kwgood...@gmail.com wrote: On Mon, Jul 19, 2010 at 10:08 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Jul 19, 2010 at 9:40 PM, Keith Goodman kwgood...@gmail.com wrote: On Mon, Jul 19, 2010 at 8:27 PM, Charles R Harris

Re: [Numpy-discussion] comparing floating point numbers

2010-07-19 Thread Keith Goodman
On Mon, Jul 19, 2010 at 6:31 PM, Ondrej Certik ond...@certik.cz wrote: Hi, I was always using something like abs(x-y) eps or (abs(x-y) eps).all() but today I needed to also make sure this works for larger numbers, where I need to compare relative errors, so I found this:

Re: [Numpy-discussion] lstsq functionality

2010-07-19 Thread Keith Goodman
On Mon, Jul 19, 2010 at 6:53 PM, Joshua Holbrook josh.holbr...@gmail.com wrote: On Mon, Jul 19, 2010 at 5:50 PM, Charles R Harris charlesr.har...@gmail.com wrote: Hi All, I'm thinking about adding some functionality to lstsq because I find myself doing the same fixes over and over. List

Re: [Numpy-discussion] lstsq functionality

2010-07-19 Thread Keith Goodman
On Mon, Jul 19, 2010 at 8:27 PM, Charles R Harris charlesr.har...@gmail.com wrote: On Mon, Jul 19, 2010 at 9:02 PM, Keith Goodman kwgood...@gmail.com wrote: On Mon, Jul 19, 2010 at 6:53 PM, Joshua Holbrook josh.holbr...@gmail.com wrote: On Mon, Jul 19, 2010 at 5:50 PM, Charles R Harris

Re: [Numpy-discussion] Matrix dot product over an axis(for a 3d array/list of matrices)

2010-07-15 Thread Keith Goodman
On Thu, Jul 15, 2010 at 9:38 AM, Emmanuel Bengio beng...@gmail.com wrote: Hello, I have a list of 4x4 transformation matrices, that I want to dot with another list of the same size (elementwise). Making a for loop that calculates the dot product of each is extremely slow, I thought that

Re: [Numpy-discussion] Matrix dot product over an axis(for a 3d array/list of matrices)

2010-07-15 Thread Keith Goodman
On Thu, Jul 15, 2010 at 9:45 AM, Keith Goodman kwgood...@gmail.com wrote: On Thu, Jul 15, 2010 at 9:38 AM, Emmanuel Bengio beng...@gmail.com wrote: Hello, I have a list of 4x4 transformation matrices, that I want to dot with another list of the same size (elementwise). Making a for loop

Re: [Numpy-discussion] Difference between shape=() and shape=(1,)

2010-07-13 Thread Keith Goodman
On Tue, Jul 13, 2010 at 9:54 AM, John Reid j.r...@mail.cryst.bbk.ac.uk wrote: Hi, I have some arrays of various shapes in which I need to set any NaNs to 0. I have been doing the following: a[numpy.where(numpy.isnan(a)] = 0. as you can see here: In [20]: a=numpy.ones(2) In [21]:

Re: [Numpy-discussion] Difference between shape=() and shape=(1,)

2010-07-13 Thread Keith Goodman
On Tue, Jul 13, 2010 at 10:45 AM, Kurt Smith kwmsm...@gmail.com wrote: You could make use of np.atleast_1d, and then everything would be canonicalized: In [33]: a = np.array(np.nan) In [34]: a Out[34]: array(nan) In [35]: a1d = np.atleast_1d(a) In [36]: a1d Out[36]: array([ NaN])

Re: [Numpy-discussion] Difference between shape=() and shape=(1,)

2010-07-13 Thread Keith Goodman
On Tue, Jul 13, 2010 at 10:36 AM, Pauli Virtanen p...@iki.fi wrote: ti, 2010-07-13 kello 10:06 -0700, Keith Goodman kirjoitti: No need to use where. You can just do a[np.isnan(a)] = 0. But you do have to watch out for 0d arrays, can't index into those. You can, but the index must

Re: [Numpy-discussion] BOF notes: Fernando's proposal: NumPy ndarray with named axes

2010-07-09 Thread Keith Goodman
. That is, you should be able to use .named directly on the top-level datarray without referring to any axis labels, to say something like arr.named['Netherlands', 2010], but you can't yet. -- Rob On Thu, Jul 8, 2010 at 11:44 PM, Keith Goodman kwgood...@gmail.com wrote: On Thu, Jul 8, 2010 at 1:20 PM

Re: [Numpy-discussion] BOF notes: Fernando's proposal: NumPy ndarray with named axes

2010-07-09 Thread Keith Goodman
On Fri, Jul 9, 2010 at 1:53 PM, Rob Speer rsp...@mit.edu wrote: Keith Goodman wrote: I ran into a few more questions while playing with datarrays, so I started a list: http://github.com/kwgoodman/datarrayQ I have quick answers to some of the questions. Thank you! Comments below. Can I

Re: [Numpy-discussion] BOF notes: Fernando's proposal: NumPy ndarray with named axes

2010-07-09 Thread Keith Goodman
On Fri, Jul 9, 2010 at 4:05 PM, Christopher Barker chris.bar...@noaa.gov wrote: So what would you get if you wanted: MyDataArray['jones':'wilson'] or MyDataArray.names[slice('jones','wilson')] or whatever the syntax would be? If it was in alphabetical order, you'd be all set, but what

Re: [Numpy-discussion] BOF notes: Fernando's proposal: NumPy ndarray with named axes

2010-07-09 Thread Keith Goodman
On Fri, Jul 9, 2010 at 5:00 PM, Christopher Barker chris.bar...@noaa.gov wrote: Keith Goodman wrote: On Fri, Jul 9, 2010 at 4:05 PM, Christopher Barker chris.bar...@noaa.gov wrote: So what would you get if you wanted: MyDataArray['jones':'wilson'] or MyDataArray.names[slice('jones

Re: [Numpy-discussion] BOF notes: Fernando's proposal: NumPy ndarray with named axes

2010-07-09 Thread Keith Goodman
On Fri, Jul 9, 2010 at 5:52 PM, Joshua Holbrook josh.holbr...@gmail.com wrote: On Fri, Jul 9, 2010 at 4:22 PM, Keith Goodman kwgood...@gmail.com wrote: On Fri, Jul 9, 2010 at 5:00 PM, Christopher Barker chris.bar...@noaa.gov wrote: Keith Goodman wrote: On Fri, Jul 9, 2010 at 4:05 PM

Re: [Numpy-discussion] [Numpy-svn] r8413 - trunk/numpy/lib - Author: oliphant - Add percentile function.

2010-07-08 Thread Keith Goodman
On Thu, Jul 8, 2010 at 12:27 PM, Sebastian Haase seb.ha...@gmail.com wrote: isn't this related to http://projects.scipy.org/numpy/ticket/626 percentile() and clamp() which was set to invalid -Sebastian The new percentile function has an axis input. I like that.

[Numpy-discussion] DataArray ticks

2010-07-08 Thread Keith Goodman
What do you think of adding a ticks parameter to DataArray? Would that make sense? Current behavior: x = DataArray([[1, 2], [3, 4]], (('row', ['A','B']), ('col', ['C', 'D']))) x.axes (Axis(label='row', index=0, ticks=['A', 'B']), Axis(label='col', index=1, ticks=['C', 'D'])) Proposed ticks

[Numpy-discussion] [ANN] la 0.4, the labeled array

2010-07-06 Thread Keith Goodman
The main class of the la package is a labeled array, larry. A larry consists of data and labels. The data is stored as a NumPy array and the labels as a list of lists (one list per dimension). Alignment by label is automatic when you add (or subtract, multiply, divide) two larrys. The focus of

Re: [Numpy-discussion] BOF notes: Fernando's proposal: NumPy ndarray with named axes

2010-07-06 Thread Keith Goodman
On Tue, Jul 6, 2010 at 7:47 AM, Joshua Holbrook josh.holbr...@gmail.com wrote: I really really really want to work on this. I already forked datarray on github and did some research on What Other People Have Done ( http://jesusabdullah.github.com/2010/07/02/datarray.html ). With any luck I'll

Re: [Numpy-discussion] BOF notes: Fernando's proposal: NumPy ndarray with named axes

2010-07-06 Thread Keith Goodman
, Jul 6, 2010 at 8:23 AM, Keith Goodman kwgood...@gmail.com wrote: On Tue, Jul 6, 2010 at 9:13 AM, Skipper Seabold jsseab...@gmail.com wrote: On Tue, Jul 6, 2010 at 11:55 AM, Keith Goodman kwgood...@gmail.com wrote: On Tue, Jul 6, 2010 at 7:47 AM, Joshua Holbrook josh.holbr...@gmail.com wrote

Re: [Numpy-discussion] [Matplotlib-users] Vectorization

2010-07-02 Thread Keith Goodman
On Fri, Jul 2, 2010 at 11:33 AM, Benjamin Root ben.r...@ou.edu wrote: I am moving this over to numpy-discussion maillist... I don't have a firm answer for you, but I did notice one issue in your code.  You call arange(len(dx) - 1) for your loops, but you probably really need arange(1, len(dx)

Re: [Numpy-discussion] [Matplotlib-users] Vectorization

2010-07-02 Thread Keith Goodman
On Fri, Jul 2, 2010 at 11:45 AM, Keith Goodman kwgood...@gmail.com wrote: On Fri, Jul 2, 2010 at 11:33 AM, Benjamin Root ben.r...@ou.edu wrote: I am moving this over to numpy-discussion maillist... I don't have a firm answer for you, but I did notice one issue in your code.  You call arange

Re: [Numpy-discussion] cython and f2py

2010-07-02 Thread Keith Goodman
On Fri, Jul 2, 2010 at 12:53 PM, Geoffrey Ely g...@usc.edu wrote: Hi All, Sorry if this has been documented or discussed already, but my searches have come up short. Can someone please recommend a way to setup both Cython and Fortran extensions in a single package with numpy.distutils (or

Re: [Numpy-discussion] construction of object arrays

2010-06-30 Thread Keith Goodman
On Wed, Jun 30, 2010 at 10:56 AM, Neal Becker ndbeck...@gmail.com wrote: What are ways to construct object arrays?  I want an array of objects, each element default constructed of a particular object type. Say my object is class A.  I want a multi-dimensional array, each element constructed

Re: [Numpy-discussion] numpy.load raising IOError but EOFError expected

2010-06-28 Thread Keith Goodman
On Wed, Jun 23, 2010 at 3:46 AM, Ruben Salvador rsalvador...@gmail.com wrote: Hi there, I have a .npy file built by succesively adding results from different test runs of an algorithm. Each time it's run, I save a numpy.array using numpy.save as follows: fn = 'file.npy' f = open(fn, 'a+b')

Re: [Numpy-discussion] Tools / data structures for statistical analysis and related applications

2010-06-11 Thread Keith Goodman
On Fri, Jun 11, 2010 at 11:51 AM, Gael Varoquaux gael.varoqu...@normalesup.org wrote: On Fri, Jun 11, 2010 at 12:57:37PM -0500, Bruce Southey wrote:  2. Do we really need to build custom data structures (larry, pandas,  tabular, etc.) or are structured ndarrays enough? (My conclusion is  that

[Numpy-discussion] actual, desired versus x, y

2010-06-03 Thread Keith Goodman
Some of the numpy.testing assert functions call the input x and y, others call it actual and desired: actual = np.array([1+1j]) desired = np.array([2+2j]) assert_almost_equal(actual, desired) snip AssertionError: Items are not equal: ACTUAL: [ 1.+1.j] DESIRED: [ 2.+2.j]

Re: [Numpy-discussion] actual, desired versus x, y

2010-06-03 Thread Keith Goodman
On Thu, Jun 3, 2010 at 10:07 AM, Keith Goodman kwgood...@gmail.com wrote: Some of the numpy.testing assert functions call the input x and y, others call it actual and desired: actual = np.array([1+1j]) desired = np.array([2+2j]) assert_almost_equal(actual, desired) snip AssertionError

Re: [Numpy-discussion] computing some running sums

2010-06-01 Thread Keith Goodman
On Tue, Jun 1, 2010 at 6:47 AM, Neal Becker ndbeck...@gmail.com wrote: Not sure what to call this. Any suggestion on computing the vector: sum(u[i*M:i*M+N]) for i in range (len(u)/M) How about a cumsum and then a loop to take the differences of the desired indices of the cumsum? Might be

Re: [Numpy-discussion] computing some running sums

2010-06-01 Thread Keith Goodman
On Tue, Jun 1, 2010 at 6:56 AM, Keith Goodman kwgood...@gmail.com wrote: On Tue, Jun 1, 2010 at 6:47 AM, Neal Becker ndbeck...@gmail.com wrote: Not sure what to call this. Any suggestion on computing the vector: sum(u[i*M:i*M+N]) for i in range (len(u)/M) How about a cumsum and then a loop

Re: [Numpy-discussion] 2D binning

2010-06-01 Thread Keith Goodman
On Tue, Jun 1, 2010 at 1:07 PM, Mathew Yeates mat.yea...@gmail.com wrote: Hi Can anyone think of a clever (non-lopping) solution to the following? A have a list of latitudes, a list of longitudes, and list of data values. All lists are the same length. I want to compute an average  of data

Re: [Numpy-discussion] ix_ and copies

2010-05-30 Thread Keith Goodman
On Sat, May 29, 2010 at 2:49 PM, Anne Archibald aarch...@physics.mcgill.ca wrote: On 29 May 2010 15:09, Robert Kern robert.k...@gmail.com wrote: On Sat, May 29, 2010 at 12:27, Keith Goodman kwgood...@gmail.com wrote: Will making changes to arr2 never change arr1 if arr2 = arr1[np.ix_(*lists

[Numpy-discussion] shuffle a slice

2010-05-29 Thread Keith Goodman
np.random.shuffle: Modify a sequence in-place by shuffling its contents. Matches doc string: a = np.arange(10) np.random.shuffle(a[:-1]) a array([0, 7, 8, 4, 3, 6, 2, 1, 5, 9]) Doesn't match doc string: l = range(10) np.random.shuffle(l[:-1]) l [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] Is

Re: [Numpy-discussion] shuffle a slice

2010-05-29 Thread Keith Goodman
On Sat, May 29, 2010 at 11:45 AM, Robert Kern robert.k...@gmail.com wrote: On Sat, May 29, 2010 at 13:35, Keith Goodman kwgood...@gmail.com wrote: np.random.shuffle: Modify a sequence in-place by shuffling its contents. Matches doc string: a = np.arange(10) np.random.shuffle(a[:-1

Re: [Numpy-discussion] How to distinguish between number and string dypes

2010-05-27 Thread Keith Goodman
On Thu, May 27, 2010 at 6:02 AM, Vincent Davis vinc...@vincentdavis.net wrote: On Thu, May 27, 2010 at 1:27 AM, Francesc Alted fal...@pytables.org wrote: A Thursday 27 May 2010 05:52:22 Vincent Davis escrigué: How do I determine if an array's (or column in a structured array) dtype is a

Re: [Numpy-discussion] __eq__ with str and object

2010-05-26 Thread Keith Goodman
, Keith Goodman wrote: a1 = np.array(['a', 'b'], dtype=object)  a2 = np.array(['a', 'b'])  a1 == a2    array([ True,  True], dtype=bool)  # Looks good  a2 == a1    False  # Should I have expected this? Could you open a ticket for this and mark it for review? Here's the ticket

[Numpy-discussion] __eq__ with str and object

2010-05-25 Thread Keith Goodman
I don't understand this: a1 = np.array(['a', 'b'], dtype=object) a2 = np.array(['a', 'b']) a1 == a2 array([ True, True], dtype=bool) # Looks good a2 == a1 False # Should I have expected this? This works like I expected: a1 = np.array([1, 2], dtype=object) a2 = np.array([1, 2])

[Numpy-discussion] The labeled array package at a glance

2010-05-23 Thread Keith Goodman
For those not familiar with the la package and its labeled array, larry, here's a table that gives you a quick overview: http://bazaar.launchpad.net/~kwgoodman/larry/trunk/annotate/head:/doc/source/intro.rst#L120 ___ NumPy-Discussion mailing list

Re: [Numpy-discussion] dtype and array creation

2010-05-20 Thread Keith Goodman
On Thu, May 20, 2010 at 1:19 PM, josef.p...@gmail.com wrote: On Thu, May 20, 2010 at 4:04 PM, Keith Goodman kwgood...@gmail.com wrote: Why do the follow expressions give different dtype? np.array([1, 2, 3], dtype=str) array(['1', '2', '3'],      dtype='|S1') np.array(np.array([1, 2, 3

[Numpy-discussion] astype None

2010-05-20 Thread Keith Goodman
While automating some unit tests for my labeled array class, larry, I assumed that np.array([1, 2], dtype=dtype) would give the same result as np.array([1, 2]).astype(dtype) But it doesn't for dtype=None: np.array([1, 2, 3], dtype=None) array([1, 2, 3]) np.array([1, 2, 3]).astype(None)

[Numpy-discussion] Numpy doc string license

2010-05-20 Thread Keith Goodman
I'd like to include modified numpy doc strings in my package. Do I just put a note in my license file that says my package contains numpy doc strings and then paste in the numpy license? My package is distributed under a Simplifed BSD license, if that matters.

Re: [Numpy-discussion] astype None

2010-05-20 Thread Keith Goodman
On Thu, May 20, 2010 at 7:36 PM, josef.p...@gmail.com wrote: On Thu, May 20, 2010 at 9:00 PM, Keith Goodman kwgood...@gmail.com wrote: While automating some unit tests for my labeled array class, larry, I assumed that np.array([1, 2], dtype=dtype) would give the same result as np.array

Re: [Numpy-discussion] Numpy doc string license

2010-05-20 Thread Keith Goodman
On Thu, May 20, 2010 at 7:38 PM, Robert Kern robert.k...@gmail.com wrote: On Thu, May 20, 2010 at 21:21, Keith Goodman kwgood...@gmail.com wrote: I'd like to include modified numpy doc strings in my package. Do I just put a note in my license file that says my package contains numpy doc

Re: [Numpy-discussion] faster code

2010-05-17 Thread Keith Goodman
On Mon, May 17, 2010 at 11:06 AM, Francesc Alted fal...@pytables.org wrote: A Sunday 16 May 2010 21:14:34 Davide Lasagna escrigué: Hi all, What is the fastest and lowest memory consumption way to compute this? y = np.arange(2**24) bases = y[1:] + y[:-1] Actually it is already quite fast,

Re: [Numpy-discussion] faster code

2010-05-16 Thread Keith Goodman
On Sun, May 16, 2010 at 12:14 PM, Davide Lasagna lasagnadav...@gmail.com wrote: Hi all, What is the fastest and lowest memory consumption way to compute this? y = np.arange(2**24) bases = y[1:] + y[:-1] Actually it is already quite fast, but i'm not sure whether it is occupying some

Re: [Numpy-discussion] faster code

2010-05-16 Thread Keith Goodman
On Sun, May 16, 2010 at 1:18 PM, Eric Firing efir...@hawaii.edu wrote: On 05/16/2010 09:24 AM, Keith Goodman wrote: On Sun, May 16, 2010 at 12:14 PM, Davide Lasagna lasagnadav...@gmail.com  wrote: Hi all, What is the fastest and lowest memory consumption way to compute this? y = np.arange(2

Re: [Numpy-discussion] Remove duplicate columns

2010-05-06 Thread Keith Goodman
On Thu, May 6, 2010 at 10:25 AM, T J tjhn...@gmail.com wrote: Hi, Is there a way to sort the columns in an array?  I need to sort it so that I can easily go through and keep only the unique columns. ndarray.sort(axis=1) doesn't do what I want as it destroys the relative ordering between the

Re: [Numpy-discussion] Question about numpy.arange()

2010-05-02 Thread Keith Goodman
On Sat, May 1, 2010 at 1:36 PM, Gökhan Sever gokhanse...@gmail.com wrote: Hello, Is b an expected value? I am suspecting another floating point arithmetic issue. I[1]: a = np.arange(1.6, 1.8, 0.1, dtype='float32') I[2]: a O[2]: array([ 1.6002,  1.7005], dtype=float32) I[3]: b =

Re: [Numpy-discussion] What should be the value of nansum of nan's?

2010-04-29 Thread Keith Goodman
On Thu, Apr 29, 2010 at 9:56 AM, Charles R Harris charlesr.har...@gmail.com wrote: It looks like the consensus is that zero should be returned. This is a change from current behaviour and that bothers me a bit. Here are some other oddities In [6]: nanmax([nan]) Out[6]: nan In [7]:

[Numpy-discussion] [ANN] la 0.2, the labeled array

2010-04-28 Thread Keith Goodman
I am pleased to announce the second release of the la package, version 0.2. The main class of the la package is a labeled array, larry. A larry consists of a data array and a label list. The data array is stored as a NumPy array and the label list as a list of lists. larry has built-in methods

Re: [Numpy-discussion] What should be the value of nansum of nan's?

2010-04-28 Thread Keith Goodman
On Mon, Apr 26, 2010 at 9:55 AM, Charles R Harris charlesr.har...@gmail.com wrote: Hi All, We need to make a decision for ticket #1123 regarding what nansum should return when all values are nan. At some earlier point it was zero, but currently it is nan, in fact it is nan whatever the

Re: [Numpy-discussion] floats as axis

2010-04-25 Thread Keith Goodman
On Sun, Apr 25, 2010 at 6:16 AM, josef.p...@gmail.com wrote: (some) numpy functions take floats as valid axis argument. Is this a feature? np.ones((2,3)).sum(1.2) array([ 3.,  3.]) np.ones((2,3)).sum(1.99) array([ 3.,  3.]) np.mean((1.5,0.5)) 1.0 np.mean(1.5,0.5) 1.5 Keith pointed

Re: [Numpy-discussion] trim_zeros in more than one dimension?

2010-04-21 Thread Keith Goodman
On Tue, Apr 20, 2010 at 6:03 AM, Andreas Hilboll li...@hilboll.de wrote: Hi there, is there an easy way to do something like trim_zeros() does, but for a n-dimensional array? I have a 2d array with only zeros in the first and last rows and columns, and would like to trim this array to only

Re: [Numpy-discussion] Find indices of largest elements

2010-04-15 Thread Keith Goodman
On Thu, Apr 15, 2010 at 12:41 PM, Nikolaus Rath nikol...@rath.org wrote: Keith Goodman kwgood...@gmail.com writes: On Wed, Apr 14, 2010 at 12:39 PM, Nikolaus Rath nikol...@rath.org wrote: Keith Goodman kwgood...@gmail.com writes: On Wed, Apr 14, 2010 at 8:49 AM, Keith Goodman kwgood

Re: [Numpy-discussion] Find indices of largest elements

2010-04-15 Thread Keith Goodman
On Thu, Apr 15, 2010 at 1:48 PM, Keith Goodman kwgood...@gmail.com wrote: On Thu, Apr 15, 2010 at 12:41 PM, Nikolaus Rath nikol...@rath.org wrote: Keith Goodman kwgood...@gmail.com writes: On Wed, Apr 14, 2010 at 12:39 PM, Nikolaus Rath nikol...@rath.org wrote: Keith Goodman kwgood

Re: [Numpy-discussion] Find indices of largest elements

2010-04-14 Thread Keith Goodman
On Wed, Apr 14, 2010 at 8:16 AM, Nikolaus Rath nikol...@rath.org wrote: Hello, How do I best find out the indices of the largest x elements in an array? Example: a = [ [1,8,2], [2,1,3] ] magic_function(a, 2) == [ (0,1), (1,2) ] Since the largest 2 elements are at positions (0,1) and

Re: [Numpy-discussion] Find indices of largest elements

2010-04-14 Thread Keith Goodman
On Wed, Apr 14, 2010 at 8:49 AM, Keith Goodman kwgood...@gmail.com wrote: On Wed, Apr 14, 2010 at 8:16 AM, Nikolaus Rath nikol...@rath.org wrote: Hello, How do I best find out the indices of the largest x elements in an array? Example: a = [ [1,8,2], [2,1,3] ] magic_function(a, 2

Re: [Numpy-discussion] Find indices of largest elements

2010-04-14 Thread Keith Goodman
On Wed, Apr 14, 2010 at 12:39 PM, Nikolaus Rath nikol...@rath.org wrote: Keith Goodman kwgood...@gmail.com writes: On Wed, Apr 14, 2010 at 8:49 AM, Keith Goodman kwgood...@gmail.com wrote: On Wed, Apr 14, 2010 at 8:16 AM, Nikolaus Rath nikol...@rath.org wrote: Hello, How do I best find out

Re: [Numpy-discussion] Find indices of largest elements

2010-04-14 Thread Keith Goodman
On Wed, Apr 14, 2010 at 1:56 PM, Keith Goodman kwgood...@gmail.com wrote: On Wed, Apr 14, 2010 at 12:39 PM, Nikolaus Rath nikol...@rath.org wrote: Keith Goodman kwgood...@gmail.com writes: On Wed, Apr 14, 2010 at 8:49 AM, Keith Goodman kwgood...@gmail.com wrote: On Wed, Apr 14, 2010 at 8:16 AM

Re: [Numpy-discussion] Find indices of largest elements

2010-04-14 Thread Keith Goodman
On Wed, Apr 14, 2010 at 3:12 PM, Anne Archibald peridot.face...@gmail.com wrote: On 14 April 2010 16:56, Keith Goodman kwgood...@gmail.com wrote: On Wed, Apr 14, 2010 at 12:39 PM, Nikolaus Rath nikol...@rath.org wrote: Keith Goodman kwgood...@gmail.com writes: On Wed, Apr 14, 2010 at 8:49 AM

Re: [Numpy-discussion] Simple way to shift array elements

2010-04-10 Thread Keith Goodman
On Sat, Apr 10, 2010 at 5:17 PM, Gökhan Sever gokhanse...@gmail.com wrote: Hello, Is there a simpler way to get c from a I[1]: a = np.arange(10) I[2]: b = a[3:] I[3]: b O[3]: array([3, 4, 5, 6, 7, 8, 9]) I[4]: c = np.insert(b, [7]*3, 0) O[5]: array([3, 4, 5, 6, 7, 8, 9, 0, 0, 0]) a

Re: [Numpy-discussion] Extracting values from one array corresponding to argmax elements in another array

2010-04-05 Thread Keith Goodman
On Mon, Apr 5, 2010 at 8:44 AM, Ken Basye kbas...@jhu.edu wrote: Hi Folks,  I have two arrays, A and B, with the same shape.  I want to find the highest values in A along some axis, then extract the corresponding values from B.  I can get the highest values in A with A.max(axis=0) and the

Re: [Numpy-discussion] lists of zeros and ones

2010-03-19 Thread Keith Goodman
On Fri, Mar 19, 2010 at 7:53 AM, gerardob gberbeg...@gmail.com wrote: Hello, i would like to produce lists of lists 1's and 0's. For example, to produce the list composed of: L = [[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]] I just need to do the following: n=4

Re: [Numpy-discussion] lists of zeros and ones

2010-03-19 Thread Keith Goodman
On Fri, Mar 19, 2010 at 8:17 AM, Joe Kington jking...@wisc.edu wrote: See itertools.permutations (python standard library) e.g. In [3]: list(itertools.permutations([1,1,0,0])) Out[3]: [(1, 1, 0, 0),  (1, 1, 0, 0),  (1, 0, 1, 0),  (1, 0, 0, 1),  (1, 0, 1, 0),  (1, 0, 0, 1),  (1, 1, 0,

Re: [Numpy-discussion] Setting small numbers to zero.

2010-03-17 Thread Keith Goodman
On Wed, Mar 17, 2010 at 8:51 AM, gerardob gberbeg...@gmail.com wrote: How can i modified all the values of a numpy array whose value is smaller than a given epsilon to zero? Example epsilon=0.01 a = [[0.003,2][23,0.0001]] output: [[0,2][23,0]] Here's one way: a =

Re: [Numpy-discussion] matrix operation

2010-03-17 Thread Keith Goodman
On Wed, Mar 17, 2010 at 11:47 AM, gerardob gberbeg...@gmail.com wrote: Let A and B be two n x n matrices. I would like to have another n x n  matrix C such that C_ij = min {A_ij, B_ij} Example: A = numpy.array([[2,3],[10,12]]) B = numpy.array([[1,4],[9,13]]) Output C = [[1,3],[9,12]]

Re: [Numpy-discussion] Setting small numbers to zero.

2010-03-17 Thread Keith Goodman
On Wed, Mar 17, 2010 at 12:04 PM, Christopher Barker chris.bar...@noaa.gov wrote: Friedrich Romstedt wrote: Code: import numpy import time a = numpy.random.random((2000, 2000)) start = time.time() a[abs(a) 10] = 0 stop = time.time() I highly recommend ipython and its timeit function

Re: [Numpy-discussion] Setting small numbers to zero.

2010-03-17 Thread Keith Goodman
On Wed, Mar 17, 2010 at 12:08 PM, Robert Kern robert.k...@gmail.com wrote: On Wed, Mar 17, 2010 at 14:03, Keith Goodman kwgood...@gmail.com wrote: On Wed, Mar 17, 2010 at 12:04 PM, Christopher Barker chris.bar...@noaa.gov wrote: Friedrich Romstedt wrote: Code: import numpy import time

Re: [Numpy-discussion] How to fix the diagonal values of a matrix

2010-03-16 Thread Keith Goodman
On Tue, Mar 16, 2010 at 5:56 AM, josef.p...@gmail.com wrote: On Tue, Mar 16, 2010 at 9:43 AM, gerardo.berbeglia gberbeg...@gmail.com wrote: How can i take out the diagonal values of a matrix and fix them to zero? Example: input: [[2,3,4],[3,4,5],[4,5,6]] output:

Re: [Numpy-discussion] How to fix the diagonal values of a matrix

2010-03-16 Thread Keith Goodman
On Tue, Mar 16, 2010 at 7:43 AM, Keith Goodman kwgood...@gmail.com wrote: On Tue, Mar 16, 2010 at 5:56 AM,  josef.p...@gmail.com wrote: On Tue, Mar 16, 2010 at 9:43 AM, gerardo.berbeglia gberbeg...@gmail.com wrote: How can i take out the diagonal values of a matrix and fix them to zero

Re: [Numpy-discussion] Request for testing

2010-02-21 Thread Keith Goodman
On Sun, Feb 21, 2010 at 2:30 AM, Charles R Harris charlesr.har...@gmail.com wrote: I would be much obliged if some folks would run the attached script and report the output, numpy version, and python version. import isinf Warning: invalid value encountered in isinf True Python 2.6.4

<    1   2   3   4   5   6   >