[Numpy-discussion] Why does np.repeat build a full array?
jni.soma at gmail.com
Tue Dec 15 01:49:59 EST 2015
I've recently been using the following pattern to create arrays of a
specific repeating value:
from numpy.lib.stride_tricks import as_strided
value = np.ones((1,), dtype=float)
arr = as_strided(value, shape=input_array.shape, strides=(0,))
I can then use arr e.g. to count certain pairs of elements using
sparse.coo_matrix. It occurred to me that numpy might have a similar
function, and found np.repeat. But it seems that repeat actually creates
the full, replicated array, rather than using stride tricks to keep it
small. Is there any reason for this?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion