[Numpy-discussion] eigenface image too dark

2008-03-18 Thread royG
hi while trying to make an eigenface image from a numpy array of floats i tried this from numpy import array import Image imagesize=(200,200) def makeimage(inputarray,imagename): inputarray.shape=(-1,) newimg=Image.new('L', imagesize) newimg.putdata(inputarray) newimg.save

[Numpy-discussion] Proposed change to average function

2008-03-18 Thread David Huard
In the process of addressing tickets for the next release, Charles Harris and I made some changes to the internals of the average function which also affects which input are accepted as valid. According to the current documentation, weights can either be 1D or any shape that can be broadcasted to

Re: [Numpy-discussion] numpy.ma bug: need sanity check in masked_where

2008-03-18 Thread Stéfan van der Walt
Hi Pierre Thanks for your fix for #703. Unfortunately, it seems to have broken some tests: http://buildbot.scipy.org/builders/Windows_XP_x86_MSVC/builds/276/steps/shell_2/logs/stdio Regards Stéfan On Mon, Mar 17, 2008 at 7:26 PM, Eric Firing <[EMAIL PROTECTED]> wrote: > Pierre, > > I just tri

Re: [Numpy-discussion] SVD error in Numpy. Bug?

2008-03-18 Thread Nils Wagner
On Tue, 18 Mar 2008 12:48:31 -0700 (PDT) Lou Pecora <[EMAIL PROTECTED]> wrote: > I have run into a failure of complex SVD in numpy > (version='1.0.3.1'). The error is: > > File > "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/numpy/linalg/linalg.py", > line 767,

Re: [Numpy-discussion] SVD error in Numpy. Bug?

2008-03-18 Thread Matthieu Brucher
Hi, I think it could happen, the search for an eignevalue is an iterative process that can diverge sometimes. All SVD implementations have this hard coded-limitation, so that the biorthogonalization can finish in finite time. What is the determinant of your matrix ? Matthieu 2008/3/18, Lou Pecor

[Numpy-discussion] SVD error in Numpy. Bug?

2008-03-18 Thread Lou Pecora
I have run into a failure of complex SVD in numpy (version='1.0.3.1'). The error is: File "/Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/numpy/linalg/linalg.py", line 767, in svd raise LinAlgError, 'SVD did not converge' numpy.linalg.linalg.LinAlgError: SVD d

Re: [Numpy-discussion] Record Arrays and ctypes Interfacing

2008-03-18 Thread vel . accel
On Tue, Mar 18, 2008 at 2:18 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > > On Tue, Mar 18, 2008 at 9:48 AM, <[EMAIL PROTECTED]> wrote: > > Hi all, > > > > How do I handle numpy record arrays (heterogenous dtype) with ctypes? > > The python side is reasonably obvious to me, but I'm confused

Re: [Numpy-discussion] Record Arrays and ctypes Interfacing

2008-03-18 Thread Robert Kern
On Tue, Mar 18, 2008 at 9:48 AM, <[EMAIL PROTECTED]> wrote: > Hi all, > > How do I handle numpy record arrays (heterogenous dtype) with ctypes? > The python side is reasonably obvious to me, but I'm confused about > how to declare my C function's signature; whether I need to include > the nump

Re: [Numpy-discussion] how to build a series of arrays as I go?

2008-03-18 Thread Robert Kern
On Tue, Mar 18, 2008 at 4:25 AM, Chris Withers <[EMAIL PROTECTED]> wrote: > Robert Kern wrote: > > Appending to a list is almost always better than growing an array by > > concatenation. If you have a real need for speed, though, there are a > > few tricks you can do at the expense of complexity

Re: [Numpy-discussion] how to build a series of arrays as I go?

2008-03-18 Thread Chris Withers
Alexander Michael wrote: > Be default (if I understand correctly) the passing a regular array to > MaskedArray will not copy it, so it less redundant than it may at > first appear. The MaskedArray provides as masked *view* of the > underlying array data you give it. Cool, that was exactly what I w

Re: [Numpy-discussion] newbie question - summing a list of arrays

2008-03-18 Thread Chris Withers
Alan G Isaac wrote: > Again: > http://www.scipy.org/Numpy_Example_List_With_Doc > > Really, as a new NumPy user you should just keep > this page open in your browser. Point well made, it's a shame that summary doesn't form part of the book... > Also, help(N.sum), of course. Ah cool. I think I g

Re: [Numpy-discussion] newbie question - summing a list of arrays

2008-03-18 Thread Alan G Isaac
On Tue, 18 Mar 2008, Chris Withers apparently wrote: > Where are the docs for sum? Again: http://www.scipy.org/Numpy_Example_List_With_Doc Really, as a new NumPy user you should just keep this page open in your browser. Also, help(N.sum), of course. Cheers, Alan Isaac __

Re: [Numpy-discussion] newbie question - summing a list of arrays

2008-03-18 Thread Chris Withers
Manuel Metz wrote: > Hm, in this case you can do it like this: > > numpy.sum(numpy.array([numpy.sum(v) for k,v in data.items()])) maybe: numpy.num(data.values(),axis=0) ...would also work? I can't actually use that though as the reason I need to do this is part of building stacked bar charts

Re: [Numpy-discussion] newbie question - summing a list of arrays

2008-03-18 Thread Manuel Metz
Chris Withers wrote: > Alan G Isaac wrote: >> On Tue, 18 Mar 2008, Chris Withers apparently wrote: >>> Say I have an aribtary number of arrays: >>> arrays = [array([1,2,3]),array([4,5,6]),array([7,8,9])] >>> How can I sum these all together? >> Try N.sum(arrays,axis=0). > > I assume N here is: >

Re: [Numpy-discussion] new question - summing a list of arrays

2008-03-18 Thread Manuel Metz
Manuel Metz wrote: > Chris Withers wrote: >> Hi All, >> >> Say I have an aribtary number of arrays: >> >> arrays = [array([1,2,3]),array([4,5,6]),array([7,8,9])] >> >> How can I sum these all together? >> >> My only solution so far is this: >> >> sum = arrays[0] >> for a in arrays[1:]: >>sum +=

Re: [Numpy-discussion] new question - summing a list of arrays

2008-03-18 Thread lorenzo bolla
use the "axis" argument in sum. L. On Tue, Mar 18, 2008 at 4:27 PM, Chris Withers <[EMAIL PROTECTED]> wrote: > Keith Goodman wrote: > >>> sum(x) > > > > matrix([[ 1.15063313], > > [ 0.8841396 ], > > [ 1.7370669 ]]) > > When these are arrays, I just get a single number sum back...

Re: [Numpy-discussion] new question - summing a list of arrays

2008-03-18 Thread Manuel Metz
Chris Withers wrote: > Hi All, > > Say I have an aribtary number of arrays: > > arrays = [array([1,2,3]),array([4,5,6]),array([7,8,9])] > > How can I sum these all together? > > My only solution so far is this: > > sum = arrays[0] > for a in arrays[1:]: >sum += a > > ...which is ugly :-S

Re: [Numpy-discussion] newbie question - summing a list of arrays

2008-03-18 Thread Chris Withers
Alan G Isaac wrote: > On Tue, 18 Mar 2008, Chris Withers apparently wrote: >> Say I have an aribtary number of arrays: >> arrays = [array([1,2,3]),array([4,5,6]),array([7,8,9])] >> How can I sum these all together? > > Try N.sum(arrays,axis=0). I assume N here is: import numpy as N? Yep, it i

Re: [Numpy-discussion] new question - summing a list of arrays

2008-03-18 Thread Chris Withers
Keith Goodman wrote: >>> sum(x) > > matrix([[ 1.15063313], > [ 0.8841396 ], > [ 1.7370669 ]]) When these are arrays, I just get a single number sum back... Chris -- Simplistix - Content Management, Zope & Python Consulting - http://www.simplistix.co.uk _

Re: [Numpy-discussion] new question - summing a list of arrays

2008-03-18 Thread Charles R Harris
On Tue, Mar 18, 2008 at 9:12 AM, Chris Withers <[EMAIL PROTECTED]> wrote: > Hi All, > > Say I have an aribtary number of arrays: > > arrays = [array([1,2,3]),array([4,5,6]),array([7,8,9])] > > How can I sum these all together? > > My only solution so far is this: > > sum = arrays[0] > for a in arr

Re: [Numpy-discussion] new question - summing a list of arrays

2008-03-18 Thread Keith Goodman
On Tue, Mar 18, 2008 at 8:12 AM, Chris Withers <[EMAIL PROTECTED]> wrote: > Hi All, > > Say I have an aribtary number of arrays: > > arrays = [array([1,2,3]),array([4,5,6]),array([7,8,9])] > > How can I sum these all together? > > My only solution so far is this: > > sum = arrays[0] > for a i

Re: [Numpy-discussion] new question - summing a list of arrays

2008-03-18 Thread Alan G Isaac
On Tue, 18 Mar 2008, Chris Withers apparently wrote: > Say I have an aribtary number of arrays: > arrays = [array([1,2,3]),array([4,5,6]),array([7,8,9])] > How can I sum these all together? Try N.sum(arrays,axis=0). But must they be in a list? An array of arrays (i.e., 2d array) is easy to sum.

[Numpy-discussion] new question - summing a list of arrays

2008-03-18 Thread Chris Withers
Hi All, Say I have an aribtary number of arrays: arrays = [array([1,2,3]),array([4,5,6]),array([7,8,9])] How can I sum these all together? My only solution so far is this: sum = arrays[0] for a in arrays[1:]: sum += a ...which is ugly :-S cheers, Chris -- Simplistix - Content Manageme

[Numpy-discussion] Record Arrays and ctypes Interfacing

2008-03-18 Thread vel . accel
Hi all, How do I handle numpy record arrays (heterogenous dtype) with ctypes? The python side is reasonably obvious to me, but I'm confused about how to declare my C function's signature; whether I need to include the numpy array interface header file or not... etc... It's not obvious to me how a

Re: [Numpy-discussion] how to build a series of arrays as I go?

2008-03-18 Thread Alexander Michael
On Tue, Mar 18, 2008 at 5:27 AM, Chris Withers <[EMAIL PROTECTED]> wrote: > Travis E. Oliphant wrote: > > Generally, arrays are not efficiently re-sized. It is best to > > pre-allocate, or simply create a list by appending and then convert to > > an array after the fact as you have done. > > T

Re: [Numpy-discussion] View ND Homogeneous Record Array as (N+1)D Array?

2008-03-18 Thread Alexander Michael
On Mon, Mar 17, 2008 at 4:55 PM, Robert Kern <[EMAIL PROTECTED]> wrote: > On Mon, Mar 17, 2008 at 3:44 PM, Alexander Michael <[EMAIL PROTECTED]> wrote: > > Is there a way to view an N-dimensional array with a *homogeneous* > > record dtype as an array of N+1 dimensions? An example will make it >

[Numpy-discussion] BUG with numpy.float64.tolist() ?

2008-03-18 Thread LB
I have two questions about numpy.float64 : - why do numpy.float64 have a tolist method, whereas standard python float hasn't ? - why does it not return list ? This seems to be the source of some bugs ( like this one, with scipy.interpolate.spalde : http://groups.google.com/group/scipy-use

Re: [Numpy-discussion] how to build a series of arrays as I go?

2008-03-18 Thread Chris Withers
Travis E. Oliphant wrote: > Generally, arrays are not efficiently re-sized. It is best to > pre-allocate, or simply create a list by appending and then convert to > an array after the fact as you have done. True, although that feels like iterating over the data twice for no reason, which feels

Re: [Numpy-discussion] how to build a series of arrays as I go?

2008-03-18 Thread Chris Withers
Robert Kern wrote: > Appending to a list is almost always better than growing an array by > concatenation. If you have a real need for speed, though, there are a > few tricks you can do at the expense of complexity. I don't for this project but I might in future, where can I read about this? chee