Re: [Numpy-discussion] __array_wrap__

2009-09-30 Thread Pauli Virtanen
Tue, 29 Sep 2009 14:55:44 -0400, Neal Becker wrote: This seems to work now, but I'm wondering if Charles is correct, that inheritance isn't such a great idea here. The advantage of inheritance is I don't have to implement forwarding all the functions, a pretty big advantage. (I wonder if

Re: [Numpy-discussion] __array_wrap__

2009-09-30 Thread Darren Dale
On Wed, Sep 30, 2009 at 2:57 AM, Pauli Virtanen pav...@iki.fi wrote: Tue, 29 Sep 2009 14:55:44 -0400, Neal Becker wrote: This seems to work now, but I'm wondering if Charles is correct, that inheritance isn't such a great idea here. The advantage of inheritance is I don't have to implement

[Numpy-discussion] how does numpy handle views and garbage collection?

2009-09-30 Thread Chris Colbert
Lets say I have function that applies a homogeneous transformation matrix to an Nx3 array of points using np.dot. since the matrix is 4x4 I have to add a 4 column of ones to the array so the function looks something like this: def foo(): --snip-- pts = np.column_stack((Xquad, Yquad,

Re: [Numpy-discussion] [SciPy-dev] Deprecate chararray [was Plea for help]

2009-09-30 Thread Michael Droettboom
In the source in my working copy. Is that going to cause problems? I wasn't sure if it was possible to document methods that didn't yet exist in the code in the wiki. Mike David Goldsmith wrote: On Tue, Sep 29, 2009 at 10:55 AM, Michael Droettboom md...@stsci.edu mailto:md...@stsci.edu

Re: [Numpy-discussion] fixed_pt prototype using aggregation

2009-09-30 Thread Neal Becker
I have implemented lots more fixed_pt operations, code attached (sorry for long lines, hope that's not a problem)import numpy as np import copy def rnd (x, frac_bits, _max): A rounding policy x1 = x (frac_bits-1) if (x1 == _max): return x1 1 else: return

Re: [Numpy-discussion] Another dumb structured array question

2009-09-30 Thread Travis Oliphant
On Sep 29, 2009, at 3:32 PM, David Warde-Farley wrote: Is there an easy way to get multiple subdtypes out? e.g. if I have a dtype dtype([('foo', 'i4'), ('bar', 'i8'), ('baz', 'S100')]) and an array with that dtype, is there a way to only get the 'foo' and 'bar'? arr[('foo','bar')]

Re: [Numpy-discussion] max value of np scalars

2009-09-30 Thread Travis Oliphant
On Sep 29, 2009, at 4:14 PM, Charles R Harris wrote: On Tue, Sep 29, 2009 at 2:52 PM, Neal Becker ndbeck...@gmail.com wrote: I need the max value of an np scalar type. I had used this code: def get_max(is_signed, base_type, total_bits): print 'get_max:', is_signed, base_type,

[Numpy-discussion] MemoryError with fancy indexing

2009-09-30 Thread Sebastian Haase
Hi, Maybe someone could explain to me what is going on here!? N.who() NameShape BytesType SLmap 2048 x 2048 16777216 int32 SLmap_fast 2048 x 2048 16777216

Re: [Numpy-discussion] how does numpy handle views and garbage collection?

2009-09-30 Thread Travis Oliphant
On Sep 30, 2009, at 6:43 AM, Chris Colbert wrote: Lets say I have function that applies a homogeneous transformation matrix to an Nx3 array of points using np.dot. since the matrix is 4x4 I have to add a 4 column of ones to the array so the function looks something like this: def foo():

Re: [Numpy-discussion] [SciPy-dev] Deprecate chararray [was Plea for help]

2009-09-30 Thread Michael Droettboom
Ralf Gommers wrote: On Wed, Sep 30, 2009 at 9:03 AM, Michael Droettboom md...@stsci.edu mailto:md...@stsci.edu wrote: In the source in my working copy. Is that going to cause problems? I wasn't sure if it was possible to document methods that didn't yet exist in the

Re: [Numpy-discussion] Another dumb structured array question

2009-09-30 Thread Skipper Seabold
On Wed, Sep 30, 2009 at 9:51 AM, Travis Oliphant oliph...@enthought.com wrote: On Sep 29, 2009, at 3:32 PM, David Warde-Farley wrote: Is there an easy way to get multiple subdtypes out? e.g. if I have a dtype dtype([('foo', 'i4'), ('bar', 'i8'), ('baz', 'S100')]) and an array with that

[Numpy-discussion] ufunc and errors

2009-09-30 Thread Dag Sverre Seljebotn
I looked and looked in the docs, but couldn't find an answer to this: When writing a ufunc, is it possible somehow to raise a Python exception (by acquiring the GIL first to raise it, set a flag and a callback which will be called with the GIL, or otherwise?). Or should one always use NaN even

Re: [Numpy-discussion] Another dumb structured array question

2009-09-30 Thread Ralf Gommers
On Wed, Sep 30, 2009 at 10:24 AM, Skipper Seabold jsseab...@gmail.comwrote: On Wed, Sep 30, 2009 at 9:51 AM, Travis Oliphant oliph...@enthought.com wrote: On Sep 29, 2009, at 3:32 PM, David Warde-Farley wrote: Is there an easy way to get multiple subdtypes out? e.g. if I have a dtype

Re: [Numpy-discussion] Question about improving genfromtxt errors

2009-09-30 Thread Skipper Seabold
On Tue, Sep 29, 2009 at 4:36 PM, Bruce Southey bsout...@gmail.com wrote: snip Hi, The first case just has to handle a missing delimiter - actually I expect that most of my cases would relate this. So here is simple Python code to generate arbitrary large list with the occasional missing

Re: [Numpy-discussion] ufunc and errors

2009-09-30 Thread Robert Kern
On Wed, Sep 30, 2009 at 09:34, Dag Sverre Seljebotn da...@student.matnat.uio.no wrote: I looked and looked in the docs, but couldn't find an answer to this: When writing a ufunc, is it possible somehow to raise a Python exception (by acquiring the GIL first to raise it, set a flag and a

Re: [Numpy-discussion] numpy macosx10.5 binaries: compa tible with 10.4?

2009-09-30 Thread denis bzowy
Russell E. Owen wrote: All the official numpy 1.3.0 Mac binaries are labelled macosx10.5. Does anyone know if these are backwards compatible with MacOS X 10.4 numpy-1.3.0-py2.5-macosx10.5.dmg works fine on macosx 10.4.11 ppc (with Python 2.5.1) -- denis

Re: [Numpy-discussion] Question about improving genfromtxt errors

2009-09-30 Thread Skipper Seabold
On Tue, Sep 29, 2009 at 4:36 PM, Bruce Southey bsout...@gmail.com wrote: Hi, The first case just has to handle a missing delimiter - actually I expect that most of my cases would relate this. So here is simple Python code to generate arbitrary large list with the occasional missing delimiter.

Re: [Numpy-discussion] Another dumb structured array question

2009-09-30 Thread Skipper Seabold
On Wed, Sep 30, 2009 at 11:01 AM, Ralf Gommers ralf.gomm...@googlemail.com wrote: On Wed, Sep 30, 2009 at 10:24 AM, Skipper Seabold jsseab...@gmail.com wrote: On Wed, Sep 30, 2009 at 9:51 AM, Travis Oliphant oliph...@enthought.com wrote: On Sep 29, 2009, at 3:32 PM, David Warde-Farley

Re: [Numpy-discussion] Convert data into rectangular grid

2009-09-30 Thread denis bzowy
jah jah.mailinglist at gmail.com writes: Hi,Suppose I have a set of x,y,c data ... matplotlib.pyplot.contour() ). JAH, is griddata() working and fast enough for you ? How many points are you contouring ? ___ NumPy-Discussion mailing list

Re: [Numpy-discussion] Another dumb structured array question

2009-09-30 Thread Ralf Gommers
On Wed, Sep 30, 2009 at 11:47 AM, Skipper Seabold jsseab...@gmail.comwrote: On Wed, Sep 30, 2009 at 11:01 AM, Ralf Gommers ralf.gomm...@googlemail.com wrote: That's really helpful to know. Is it too early to document this on the wiki http://docs.scipy.org/doc/numpy/user/basics.rec.html?

Re: [Numpy-discussion] Another dumb structured array question

2009-09-30 Thread Skipper Seabold
On Wed, Sep 30, 2009 at 12:00 PM, Ralf Gommers ralf.gomm...@googlemail.com wrote: No, all the docs should be in the wiki. The page corresponding to the link you gave is http://docs.scipy.org/numpy/docs/numpy.doc.structured_arrays/ And if you use diff to svn on that page you can see that it

Re: [Numpy-discussion] Question about improving genfromtxt errors

2009-09-30 Thread Bruce Southey
On 09/30/2009 10:22 AM, Skipper Seabold wrote: On Tue, Sep 29, 2009 at 4:36 PM, Bruce Southeybsout...@gmail.com wrote: snip Hi, The first case just has to handle a missing delimiter - actually I expect that most of my cases would relate this. So here is simple Python code to generate

Re: [Numpy-discussion] Question about improving genfromtxt errors

2009-09-30 Thread Skipper Seabold
On Wed, Sep 30, 2009 at 12:56 PM, Bruce Southey bsout...@gmail.com wrote: On 09/30/2009 10:22 AM, Skipper Seabold wrote: On Tue, Sep 29, 2009 at 4:36 PM, Bruce Southeybsout...@gmail.com  wrote: snip Hi, The first case just has to handle a missing delimiter - actually I expect that most of

[Numpy-discussion] Compound conditional indexing

2009-09-30 Thread Gökhan Sever
Hello, How to conditionally index an array as shown below : a = arange(10) a[5a8] to get array([6,7]) I can't do this with where either. What is the cure for this? Thanks. -- Gökhan ___ NumPy-Discussion mailing list NumPy-Discussion@scipy.org

Re: [Numpy-discussion] Compound conditional indexing

2009-09-30 Thread Joe Kington
There may be a more elegant way, but: In [2]: a = np.arange(10) In [3]: a[(a5) (a8)] Out[3]: array([6, 7]) On Wed, Sep 30, 2009 at 1:27 PM, Gökhan Sever gokhanse...@gmail.com wrote: Hello, How to conditionally index an array as shown below : a = arange(10) a[5a8] to get array([6,7])

Re: [Numpy-discussion] Compound conditional indexing

2009-09-30 Thread Christopher Barker
Gökhan Sever wrote: How to conditionally index an array as shown below : a = arange(10) a[5a8] to get array([6,7]) In [56]: a[(5a) (a8)] Out[56]: array([6, 7]) not as efficient as it might be, but it works. -Chris -- Christopher Barker, Ph.D. Oceanographer Emergency Response

Re: [Numpy-discussion] Compound conditional indexing

2009-09-30 Thread Gökhan Sever
Thanks this works. My second question how to access a second array using this condition? I am trying slice another array using a compound condition on the reference array. say: a = 1,2,3,4,5, b = 20,30,40,50,60 I want to get elements of a only when a = 3,4. I know I need indices but how ?

Re: [Numpy-discussion] Compound conditional indexing

2009-09-30 Thread Robert Kern
On Wed, Sep 30, 2009 at 14:40, Gökhan Sever gokhanse...@gmail.com wrote: Thanks this works. My second question how to access a second array using this condition? I am trying slice another array using a compound condition on the reference array. say: a = 1,2,3,4,5, b = 20,30,40,50,60 I

Re: [Numpy-discussion] Compound conditional indexing

2009-09-30 Thread Gökhan Sever
On Wed, Sep 30, 2009 at 2:45 PM, Robert Kern robert.k...@gmail.com wrote: On Wed, Sep 30, 2009 at 14:40, Gökhan Sever gokhanse...@gmail.com wrote: Thanks this works. My second question how to access a second array using this condition? I am trying slice another array using a compound

Re: [Numpy-discussion] [SciPy-dev] Deprecate chararray [was Plea for help]

2009-09-30 Thread David Goldsmith
So, Ralf (or anyone), how, if at all, should we modify the status of the existing chararray objects/methods in the wiki? Assuming you have no problem sharing them with me, Michael, I could add those docstrings you created for the existing methods, and we can promote them to Ready for Review; they

[Numpy-discussion] scipy.reddit.com

2009-09-30 Thread David Warde-Farley
In the spirit of the 'advice' site, and given that we're thinking of moving scipy.org to more static content (once I have some free time on my hands again, which should be soon!), I set up a 'subreddit' on reddit.com for Python-in-Science related links. I even came up with a somewhat

Re: [Numpy-discussion] [SciPy-dev] Deprecate chararray [was Plea for help]

2009-09-30 Thread Ralf Gommers
On Wed, Sep 30, 2009 at 4:37 PM, David Goldsmith d.l.goldsm...@gmail.comwrote: So, Ralf (or anyone), how, if at all, should we modify the status of the existing chararray objects/methods in the wiki? Nothing has to be done until *after* Mike has committed his changes to svn. Please see my

Re: [Numpy-discussion] [SciPy-dev] Deprecate chararray [was Plea for help]

2009-09-30 Thread David Goldsmith
On Wed, Sep 30, 2009 at 2:09 PM, Ralf Gommers ralf.gomm...@googlemail.comwrote: On Wed, Sep 30, 2009 at 4:37 PM, David Goldsmith d.l.goldsm...@gmail.comwrote: So, Ralf (or anyone), how, if at all, should we modify the status of the existing chararray objects/methods in the wiki? Nothing

Re: [Numpy-discussion] Another dumb structured array question

2009-09-30 Thread David Warde-Farley
On 30-Sep-09, at 9:51 AM, Travis Oliphant wrote: Try (with a later version of NumPy --- possibly trunk): arr[['foo', 'bar']] (i.e. with a list instead of a tuple) Aha! Thanks Travis. I guess tuples for multi-dimensional indexing _and_ multi-field indexing would be semantically awkward,

Re: [Numpy-discussion] Convert data into rectangular grid

2009-09-30 Thread jah
On Wed, Sep 30, 2009 at 8:57 AM, denis bzowy denis-bz...@t-online.dewrote: jah jah.mailinglist at gmail.com writes: Hi,Suppose I have a set of x,y,c data ... matplotlib.pyplot.contour() ). JAH, is griddata() working and fast enough for you ? How many points are you contouring ?

[Numpy-discussion] repr and object arrays

2009-09-30 Thread Charles R Harris
Hi All, It seems that repr applied do an object array does not provide the info needed to recreate it: In [22]: y = array([Decimal(1)]*2) In [23]: repr(y) Out[23]: 'array([1, 1], dtype=object)' And of course, there is going to be a problem with arrays of more than one dimension anyway. But I

Re: [Numpy-discussion] repr and object arrays

2009-09-30 Thread Robert Kern
On Wed, Sep 30, 2009 at 21:45, Charles R Harris charlesr.har...@gmail.com wrote: Hi All, It seems that repr applied do an object array does not provide the info needed to recreate it: In [22]: y = array([Decimal(1)]*2) In [23]: repr(y) Out[23]: 'array([1, 1], dtype=object)' And of