Re: [Numpy-discussion] save a matrix

2006-11-30 Thread Charles R Harris
On 11/30/06, Charles R Harris <[EMAIL PROTECTED]> wrote: On 11/30/06, Keith Goodman <[EMAIL PROTECTED]> wrote: > > On 11/30/06, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > > It is also possible to put the variables of interest in a dictionary, > then > > pickle the dictionary. That way y

Re: [Numpy-discussion] save a matrix

2006-11-30 Thread Charles R Harris
On 11/30/06, Keith Goodman <[EMAIL PROTECTED]> wrote: On 11/30/06, Charles R Harris <[EMAIL PROTECTED]> wrote: > > It is also possible to put the variables of interest in a dictionary, then > pickle the dictionary. That way you can also store the variable names. > > In [27]: f = open(' dump.pkl'

Re: [Numpy-discussion] save a matrix

2006-11-30 Thread Keith Goodman
On 11/30/06, Charles R Harris <[EMAIL PROTECTED]> wrote: > > It is also possible to put the variables of interest in a dictionary, then > pickle the dictionary. That way you can also store the variable names. > > In [27]: f = open(' dump.pkl','w') > > In [28]: pickle.dump( {'a':a,'b':b}, f) > > In

Re: [Numpy-discussion] save a matrix

2006-11-30 Thread Charles R Harris
On 11/30/06, Charles R Harris <[EMAIL PROTECTED]> wrote: On 11/30/06, Keith Goodman <[EMAIL PROTECTED]> wrote: > > What's a good way to save matrix objects to file for later use? I just > need something quick for debugging. > > I saw two suggestions on this list from Francesc Altet (2006-05-22

Re: [Numpy-discussion] save a matrix

2006-11-30 Thread Keith Goodman
On 11/30/06, Charles R Harris <[EMAIL PROTECTED]> wrote: > > > On 11/30/06, Keith Goodman <[EMAIL PROTECTED]> wrote: > > What's a good way to save matrix objects to file for later use? I just > > need something quick for debugging. > > > > I saw two suggestions on this list from Francesc Altet (200

Re: [Numpy-discussion] save a matrix

2006-11-30 Thread Charles R Harris
On 11/30/06, Keith Goodman <[EMAIL PROTECTED]> wrote: What's a good way to save matrix objects to file for later use? I just need something quick for debugging. I saw two suggestions on this list from Francesc Altet (2006-05-22): 1. Use tofile and fromfile and save the meta data yourself. 2.

[Numpy-discussion] save a matrix

2006-11-30 Thread Keith Goodman
What's a good way to save matrix objects to file for later use? I just need something quick for debugging. I saw two suggestions on this list from Francesc Altet (2006-05-22): 1. Use tofile and fromfile and save the meta data yourself. 2. pytables Any suggestions for #3? If I do #1, how would

Re: [Numpy-discussion] strange behavior with a numpy array as member of a list

2006-11-30 Thread Robert Kern
Christopher Barker wrote: > > Robert Kern wrote: > >>> What determines if an array tests for equality as the entire array or >>> element-wise? >> There are some special cases for backwards compatibility. > > with what? > > IIRC, Numeric has raised an error for a very long time with: > > a ==

Re: [Numpy-discussion] strange behavior with a numpy array as member of a list

2006-11-30 Thread Christopher Barker
Robert Kern wrote: >> What determines if an array tests for equality as the entire array or >> element-wise? > > There are some special cases for backwards compatibility. with what? IIRC, Numeric has raised an error for a very long time with: a == None #(a is a Numeric array) Personally,

Re: [Numpy-discussion] strange behavior with a numpy array as member of a list

2006-11-30 Thread Tim Hirzel
Excellent. That explains it. thank you Robert, tim Robert Kern wrote: > Tim Hirzel wrote: > >> Thanks Robert. >> That makes more sense now. Although I am still a little puzzled by the >> equality behavior of an array. for example: >> >> >>> a = numpy.arange(5) >> >>> None == a >> False >>

Re: [Numpy-discussion] strange behavior with a numpy array as member of a list

2006-11-30 Thread Robert Kern
Tim Hirzel wrote: > Thanks Robert. > That makes more sense now. Although I am still a little puzzled by the > equality behavior of an array. for example: > > >>> a = numpy.arange(5) > >>> None == a > False > > >>> 5 == a > array([False, False, False, False, False], dtype=bool) > > >>> cla

Re: [Numpy-discussion] strange behavior with a numpy array as member of a list

2006-11-30 Thread Tim Hirzel
Thanks Robert. That makes more sense now. Although I am still a little puzzled by the equality behavior of an array. for example: >>> a = numpy.arange(5) >>> None == a False >>> 5 == a array([False, False, False, False, False], dtype=bool) >>> class Empty: pass >>> e = Empty() >>> e

Re: [Numpy-discussion] strange behavior with a numpy array as member of a list

2006-11-30 Thread Robert Kern
Tim Hirzel wrote: > Does this seem odd to anyone else? I am not sure about the > implementation of 'in' but it seems like a comparison is going funny > somewhere. Or I am missing something... Yes, list.__contains__ uses equality to test for membership, not identity. -- Robert Kern "I have c

[Numpy-discussion] strange behavior with a numpy array as member of a list

2006-11-30 Thread Tim Hirzel
Hi All, When a list contains a numpy array and I want to see if a value is a member of that list, I can get a value error from numpy: >>> import numpy >>> numpy.__version__ '1.0' >>> a = numpy.arange(10) >>> L = [a] >>> a in L True >>> 2 in L Traceback (most recent call last): File "", lin

[Numpy-discussion] bare bones numpy extension code

2006-11-30 Thread John Hunter
A colleague of mine wants to write some numpy extension code. I pointed him to lots of examples in the matplotlib src dir, but the build environment is more complicated than he needs with all the numpy/numeric/numarray switches, etc. Does someone have the basic "hello world" of numpy extensions

Re: [Numpy-discussion] atol in allclose

2006-11-30 Thread Robert Kern
Charles R Harris wrote: > I think that's right. Do you want to make the change? Done. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Ec

Re: [Numpy-discussion] extremely slow array indexing?

2006-11-30 Thread Tim Hochberg
Fang Fang wrote: > Thanks for your reply. The simplified code is as follows. It takes 7 > seconds to process 1000 rows, which is tolerable, but I wonder why it > takes so long. Isn't vectorized operation supposed to run very quickly. > > from numpy import * > > componentcount = 30 > currSum =

Re: [Numpy-discussion] extremely slow array indexing?

2006-11-30 Thread Robert Kern
Fang Fang wrote: > Thanks for your reply. The simplified code is as follows. It takes 7 > seconds to process 1000 rows, which is tolerable, but I wonder why it > takes so long. Isn't vectorized operation supposed to run very quickly. One problem is that you are creating a new currSum array for eve

Re: [Numpy-discussion] extremely slow array indexing?

2006-11-30 Thread Fang Fang
Thanks for your reply. The simplified code is as follows. It takes 7 seconds to process 1000 rows, which is tolerable, but I wonder why it takes so long. Isn't vectorized operation supposed to run very quickly. from numpy import * componentcount = 30 currSum = zeros(componentcount) row = zer

Re: [Numpy-discussion] extremely slow array indexing?

2006-11-30 Thread Robert Kern
Fang Fang wrote: > Hi, > > I am writing code to sort the columns according to the sum of each > column. The dataset is huge (50k rows x 300k cols), so i have to read > line by line and do the summation to avoid the out-of-memory problem. > But I don't know why it runs very slow, and part of the co

[Numpy-discussion] extremely slow array indexing?

2006-11-30 Thread Fang Fang
Hi, I am writing code to sort the columns according to the sum of each column. The dataset is huge (50k rows x 300k cols), so i have to read line by line and do the summation to avoid the out-of-memory problem. But I don't know why it runs very slow, and part of the code is as follows. Can anyone

Re: [Numpy-discussion] ScientificPython with NumPy

2006-11-30 Thread Konrad Hinsen
On Nov 29, 2006, at 1:09, Travis Oliphant wrote: > You can > > #define PY_SSIZE_T_MIN INT_MIN > #define PY_SSIZE_T_MAX INT_MAX > > before including the NumPy header file and it will by-pass the typedef > for Py_ssize_t. Interesting. Is that a test that would work for distinguishing Python 2.5 f

Re: [Numpy-discussion] array with object

2006-11-30 Thread Robert Kern
Lionel Roubeyrie wrote: > Hi Torgil, > strange, I don't have the same error: > > |~|[2]>array(['2'],dtype=float32) > --- > exceptions.ValueErrorTraceback

Re: [Numpy-discussion] array with object

2006-11-30 Thread Lionel Roubeyrie
Hi Torgil, strange, I don't have the same error: |~|[2]>array(['2'],dtype=float32) --- exceptions.ValueErrorTraceback (most recent call last) /home/lione