Re: [Numpy-discussion] Constant array

2006-08-28 Thread Charles R Harris
Hi Carlos,On 8/27/06, Carlos Pita [EMAIL PROTECTED] wrote: Hi all!Is there a more efficient way of creating a constant K-valued array of size N than:zeros(N) + K?Maybe something like this:I n [12]: a = empty((3,3), dtype=int)In [13]: a.fill(11) In [14]: aOut[14]: array([[11, 11, 11], [11, 11,

Re: [Numpy-discussion] odd import behavior

2006-08-28 Thread Travis Oliphant
Matthew Auger wrote: I recently installed python2.5c1, numpy-1.0b3, and matplotlib-0.87.4. I was getting an error when importing pylab that led me to this curious behavior: matplotlib-0.87.4 is *not* compatible with 1.0b2 and above. A new version needs to be released to work with

Re: [Numpy-discussion] bad generator behaviour with sum

2006-08-28 Thread Travis Oliphant
Tom Denniston wrote: I was thinking about this in the context of Giudo's comments at scipy 2006 that much of the language is moving away from lists toward iterators. He gave the keys of a dict as an example. Numpy treats iterators, generators, etc as 0x0 PyObjects rather than lazy

Re: [Numpy-discussion] Optimizing mean(axis=0) on a 3D array

2006-08-28 Thread Martin Spacek
Tim Hochberg wrote: I'm actually surprised that the take version is faster than my original version since it makes a big ol' copy. I guess this is an indication that indexing is more expensive than I realize. That's why nothing beats measuring! Actually, your original version is just as

Re: [Numpy-discussion] Optimizing mean(axis=0) on a 3D array

2006-08-28 Thread Martin Spacek
Martin Spacek wrote: Actually, your original version is just as fast as the take() version. Both are about 9X faster than numpy.mean() on my system. I prefer the take() version because you only have to pass a single argument to mean_accum() I forgot to mention that all my indices are,

Re: [Numpy-discussion] memory corruption bug

2006-08-28 Thread Sven Schreiber
Charles R Harris schrieb: +1. I too suspect that what you have here is a reference/copy problem. The only thing that is local to the class is the reference (pointer), the data is global. Chuck Ok, so you guys were right, turns out that my problem was caused by the fact that a local

Re: [Numpy-discussion] memory corruption bug

2006-08-28 Thread Bill Baxter
Nope, that's the way python works in general for any type other than basic scalar types. a = [1,2,3,4] b = a b[1] = 99 print a [1, 99, 3, 4] print b [1, 99, 3, 4] Also the issue never comes up for types like tuples or strings because they aren't mutable. --bb On 8/28/06, Sven Schreiber

Re: [Numpy-discussion] C Api newbie question

2006-08-28 Thread Matt Knox
Matt Knox wrote: Hi there. I'm in the unfortunate situation of trying to track down a memory error in someone elses code, and to make matters worse I don't really know jack squat about C programming. The problem seems to arise when several numpy arrays are created from C arrays in the C api

[Numpy-discussion] numpy1.04b4: undefined symbol: PyUnicodeUCS2_FromUnicode. error No _WIN32

2006-08-28 Thread rex
Numpy builds, but fails to run with the error message: python Python 2.4.2 (#1, Apr 24 2006, 18:13:30) [GCC 4.1.0 (SUSE 10.1 Linux)] on linux2 import numpy Traceback (most recent call last): File stdin, line 1, in ? File /usr/lib/python2.4/site-packages/numpy/__init__.py, line 35, in ?

Re: [Numpy-discussion] request for new array method: arr.abs()

2006-08-28 Thread Christopher Barker
Travis Oliphant wrote: Instead, I like better the idea of adding abs, round, max, and min to the non-import-* namespace of numpy. Another I'd like is the built-in data types. I always use: import numpy as N so then I do: a = zeros(shape, float) or a = zeros(shape, N.float_) but for

Re: [Numpy-discussion] numpy1.04b4: undefined symbol: PyUnicodeUCS2_FromUnicode. error No _WIN32

2006-08-28 Thread Travis Oliphant
rex wrote: Numpy builds, but fails to run with the error message: python Python 2.4.2 (#1, Apr 24 2006, 18:13:30) [GCC 4.1.0 (SUSE 10.1 Linux)] on linux2 import numpy Traceback (most recent call last): File stdin, line 1, in ? File

Re: [Numpy-discussion] request for new array method: arr.abs()

2006-08-28 Thread Travis Oliphant
Christopher Barker wrote: Travis Oliphant wrote: Instead, I like better the idea of adding abs, round, max, and min to the non-import-* namespace of numpy. Another I'd like is the built-in data types. I always use: import numpy as N so then I do: a = zeros(shape, float) or

[Numpy-discussion] Numeric/numpy incompatibility

2006-08-28 Thread Andrew Straw
The following code indicates there is a problem adding a numpy scalar type to a Numeric array. Is this expected behavior or is there a bug somewhere? This bit me in the context of updating some of my code to numpy, while part of it still uses Numeric. import Numeric import numpy print

[Numpy-discussion] weave using numeric or numpy?

2006-08-28 Thread Carlos Pita
Hi all!I'm rewriting some swig-based extensions that implement intensive inner loops dealing with numeric/numpy arrays. The intention is to build these extensions by means of weave inline, ext_module, ext_function, etc. I'm not sure about how to point weave to my numpy instalation. By default it

[Numpy-discussion] 1.0b4 problem continuted from 1.0b3

2006-08-28 Thread kortmann
On 8/25/06, Travis Oliphant [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Message: 4 Date: Thu, 24 Aug 2006 14:17:44 -0600 From: Travis Oliphant [EMAIL PROTECTED] Subject: Re: [Numpy-discussion] (no subject) To: Discussion of Numerical Python

Re: [Numpy-discussion] 1.0b4 problem continuted from 1.0b3

2006-08-28 Thread Travis Oliphant
[EMAIL PROTECTED] wrote: On 8/25/06, Travis Oliphant [EMAIL PROTECTED] wrote: [EMAIL PROTECTED] wrote: Message: 4 Date: Thu, 24 Aug 2006 14:17:44 -0600 From: Travis Oliphant [EMAIL PROTECTED] Subject: Re: [Numpy-discussion] (no subject) To: Discussion of Numerical Python

Re: [Numpy-discussion] request for new array method: arr.abs()

2006-08-28 Thread Christopher Barker
Travis Oliphant wrote: I think I prefer to just add the float, bool, object, unicode, str names to the non-imported numpy name-space. which mean you get it with: import numpy as N N.float but not with from numpy import * ? If that's what you mean, then I'm all for it! -Chris --

[Numpy-discussion] Is numpy supposed to support the buffer protocol?

2006-08-28 Thread Christopher Barker
HI all, Robin Dunn has been working on adding better support for dumping data directly to wxPython from the num* packages. I've been talking to him about the new array interface, and he might well support it (particularly if one of us contributes code), but in the meantime, he's got a number

Re: [Numpy-discussion] Is numpy supposed to support the buffer protocol?

2006-08-28 Thread Travis Oliphant
Christopher Barker wrote: HI all, File /usr/lib/python2.4/site-packages/wx-2.6-gtk2-unicode/wx/_core.py, line 2814, in SetDataBuffer return _core_.Image_SetDataBuffer(*args, **kwargs) TypeError: non-character array cannot be interpreted as character buffer If I try to pass in a

Re: [Numpy-discussion] Is numpy supposed to support the buffer protocol?

2006-08-28 Thread Robert Kern
Christopher Barker wrote: While I'm a great advocate of the new array protocol, it seems supporting the buffer protocol also would be a good idea. I've enclosed some simple test code. It works with numarray, but not numpy 1.0b4 Instead of I.SetDataBuffer(some_array) you can use

Re: [Numpy-discussion] 1.0b4 problem continuted from 1.0b3

2006-08-28 Thread Torgil Svensson
This is really a matplotlib problem. From matplotlib users mailing-list archives: From: Charlie Moad [EMAIL PROTECTED] Snapshot build for use with numpy-1.0b3 2006-08-23 06:11 Here is a snapshot of svn this morning for those wanting to work with the numpy beta. Both builds are for

[Numpy-discussion] A minor annoyance with MA

2006-08-28 Thread PGM
Folks, I keep running into the following problem since some recent update (I'm currently running 1.0b3, but the problem occurred roughly around 0.9.8): import numpy.core.ma as MA x=MA.array([[1],[2]],mask=False) x.sum(None) /usr/lib64/python2.4/site-packages/numpy/core/ma.py in reduce(self,