[Numpy-discussion] simple array help?

Pete Shinners pete at shinners.org
Mon Oct 16 22:58:56 CDT 2000


i have a simple array with floating values
>>> print a
array([ 0. ,  0.2,  0.4,  0.6,  0.8])

what i need to do is change each index into another
dimension with 3 indices. hmm, kind of confusing, an
example will explain better

>>> b = array(zip(a,a,a))
>>> print b
array([[ 0. ,  0. ,  0. ],
       [ 0.2,  0.2,  0.2],
       [ 0.4,  0.4,  0.4],
       [ 0.6,  0.6,  0.6],
       [ 0.8,  0.8,  0.8]])

ok, this does the job, but once i start using large
arrays, the back-n-forth conversion between arrays and
python lists is costing me quite a bit. is there a way
i can reshape the array this way without the call to
python's 'zip'? (no, 'map' doesn't count either)

i've tried much fooling with NewAxis, resize, and friends.
but either i haven't stumbled upon the correct combination
or i'm not trying the correct tools. i'd like to keep this
as quick as possible, so hopefully it can be done without
anything too elaborate.

thanks

(doh, sorry for the previous distutils related post...
hit the wrong mailing list)





More information about the Numpy-discussion mailing list