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] 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