MCPcopy
hub / github.com/numpy/numpy / repeat

Function repeat

numpy/_core/fromnumeric.py:438–481  ·  view source on GitHub ↗

Repeat each element of an array after themselves Parameters ---------- a : array_like Input array. repeats : int or array of ints The number of repetitions for each element. `repeats` is broadcasted to fit the shape of the given axis. axis : int, op

(a, repeats, axis=None)

Source from the content-addressed store, hash-verified

436
437@array_function_dispatch(_repeat_dispatcher)
438def repeat(a, repeats, axis=None):
439 """
440 Repeat each element of an array after themselves
441
442 Parameters
443 ----------
444 a : array_like
445 Input array.
446 repeats : int or array of ints
447 The number of repetitions for each element. `repeats` is broadcasted
448 to fit the shape of the given axis.
449 axis : int, optional
450 The axis along which to repeat values. By default, use the
451 flattened input array, and return a flat output array.
452
453 Returns
454 -------
455 repeated_array : ndarray
456 Output array which has the same shape as `a`, except along
457 the given axis.
458
459 See Also
460 --------
461 tile : Tile an array.
462 unique : Find the unique elements of an array.
463
464 Examples
465 --------
466 >>> import numpy as np
467 >>> np.repeat(3, 4)
468 array([3, 3, 3, 3])
469 >>> x = np.array([[1,2],[3,4]])
470 >>> np.repeat(x, 2)
471 array([1, 1, 2, 2, 3, 3, 4, 4])
472 >>> np.repeat(x, 3, axis=1)
473 array([[1, 1, 1, 2, 2, 2],
474 [3, 3, 3, 4, 4, 4]])
475 >>> np.repeat(x, [1, 2], axis=0)
476 array([[1, 2],
477 [3, 4],
478 [3, 4]])
479
480 """
481 return _wrapfunc(a, 'repeat', repeats, axis=axis)
482
483
484def _put_dispatcher(a, ind, v, mode=None):

Callers 3

test_copyMethod · 0.90
performance.pyFile · 0.85
test_testCopySizeMethod · 0.85

Calls 1

_wrapfuncFunction · 0.85

Tested by 2

test_copyMethod · 0.72
test_testCopySizeMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…