Re: Expanding a vector by replicating elements individually

2010-09-24 Thread gburde...@gmail.com
On Sep 22, 1:30 am, Peter Otten <__pete...@web.de> wrote: > > array([1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) > > Peter Thanks! -- http://mail.python.org/mailman/listinfo/python-list

Re: Expanding a vector by replicating elements individually

2010-09-22 Thread Robert Kern
On 9/21/10 10:03 PM, gburde...@gmail.com wrote: Given m=numpy.array([[1, 2, 3]]) I want to obtain array([[1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]]) One way I've found to do this is: numpy.reshape(numpy.tile(m,(4,1)),(12,1),'f').T Another way is: numpy.reshape(numpy.tile(m,(4,1)).flatten(1),(1,

Re: Expanding a vector by replicating elements individually

2010-09-22 Thread Terry Reedy
On 9/21/2010 11:03 PM, gburde...@gmail.com wrote: Given m=numpy.array([[1, 2, 3]]) I want to obtain array([[1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]]) One way I've found to do this is: numpy.reshape(numpy.tile(m,(4,1)),(12,1),'f').T Another way is: numpy.reshape(numpy.tile(m,(4,1)).flatten(1),(

Re: Expanding a vector by replicating elements individually

2010-09-21 Thread Peter Otten
gburde...@gmail.com wrote: > Given > > m=numpy.array([[1, 2, 3]]) > > I want to obtain > > array([[1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]]) >>> numpy.array([1,2,3]).repeat(4) array([1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]) Peter -- http://mail.python.org/mailman/listinfo/python-list

Expanding a vector by replicating elements individually

2010-09-21 Thread gburde...@gmail.com
Given m=numpy.array([[1, 2, 3]]) I want to obtain array([[1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3]]) One way I've found to do this is: numpy.reshape(numpy.tile(m,(4,1)),(12,1),'f').T Another way is: numpy.reshape(numpy.tile(m,(4,1)).flatten(1),(1,12)) Is there a simpler way to do this, without h