MCPcopy Index your code
hub / github.com/numpy/numpy / pad

Function pad

numpy/lib/_arraypad_impl.py:547–926  ·  view source on GitHub ↗

Pad an array. Parameters ---------- array : array_like of rank N The array to pad. pad_width : {sequence, array_like, int, dict} Number of values padded to the edges of each axis. ``((before_1, after_1), ... (before_N, after_N))`` unique pad widths

(array, pad_width, mode='constant', **kwargs)

Source from the content-addressed store, hash-verified

545
546@array_function_dispatch(_pad_dispatcher, module='numpy')
547def pad(array, pad_width, mode='constant', **kwargs):
548 """
549 Pad an array.
550
551 Parameters
552 ----------
553 array : array_like of rank N
554 The array to pad.
555 pad_width : {sequence, array_like, int, dict}
556 Number of values padded to the edges of each axis.
557 ``((before_1, after_1), ... (before_N, after_N))`` unique pad widths
558 for each axis.
559 ``(before, after)`` or ``((before, after),)`` yields same before
560 and after pad for each axis.
561 ``(pad,)`` or ``int`` is a shortcut for before = after = pad width
562 for all axes.
563 If a ``dict``, each key is an axis and its corresponding value is an ``int`` or
564 ``int`` pair describing the padding ``(before, after)`` or ``pad`` width for
565 that axis.
566 mode : str or function, optional
567 One of the following string values or a user supplied function.
568
569 'constant' (default)
570 Pads with a constant value.
571 'edge'
572 Pads with the edge values of array.
573 'linear_ramp'
574 Pads with the linear ramp between end_value and the
575 array edge value.
576 'maximum'
577 Pads with the maximum value of all or part of the
578 vector along each axis.
579 'mean'
580 Pads with the mean value of all or part of the
581 vector along each axis.
582 'median'
583 Pads with the median value of all or part of the
584 vector along each axis.
585 'minimum'
586 Pads with the minimum value of all or part of the
587 vector along each axis.
588 'reflect'
589 Pads with the reflection of the vector mirrored on
590 the first and last values of the vector along each
591 axis.
592 'symmetric'
593 Pads with the reflection of the vector mirrored
594 along the edge of the array.
595 'wrap'
596 Pads with the wrap of the vector along the axis.
597 The first values are used to pad the end and the
598 end values are used to pad the beginning.
599 'empty'
600 Pads with undefined values.
601
602 <function>
603 Padding function, see Notes.
604 stat_length : sequence or int, optional

Callers

nothing calls this directly

Calls 13

ndindexClass · 0.90
_as_pairsFunction · 0.85
_pad_simpleFunction · 0.85
_view_roiFunction · 0.85
_set_pad_areaFunction · 0.85
anyFunction · 0.85
_get_edgesFunction · 0.85
_get_linear_rampsFunction · 0.85
_get_statsFunction · 0.85
_set_reflect_bothFunction · 0.85
_set_wrap_bothFunction · 0.85
itemsMethod · 0.80

Tested by

no test coverage detected