Hello,

In order to repeat rows or columns of an array as
http://stackoverflow.com/questions/1550130/cloning-row-or-column-vectors
I can use np.repeat as suggested by pv. However, looking at the flags of
the resulting array, data seems to be copied and actually repeated in
memory. This is not applicable if want a 1000x repetition.

What are the other options for such a repeat ?

On scipy lectures, there is a suggestion to use as_strided :
http://scipy-lectures.github.io/advanced/advanced_numpy/#example-fake-dimensions-with-strides

Otherwise, I see broadcast_arrays :

> N = 3
> data = np.arange(N)
> np.broadcast_arrays(data[:,None], np.zeros((1,2)))[0]
array([[0, 0],
       [1, 1],
       [2, 2]])

This works but it feels like invoking a magic formula. Did I miss a
simpler function ?

best,
Pierre

<<attachment: pierre_haessig.vcf>>

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to