MCPcopy Create free account
hub / github.com/numpy/numpy / pad

Function pad

numpy/lib/arraypad.py:534–882  ·  view source on GitHub ↗

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

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

Source from the content-addressed store, hash-verified

532
533@array_function_dispatch(_pad_dispatcher, module='numpy')
534def pad(array, pad_width, mode='constant', **kwargs):
535 """
536 Pad an array.
537
538 Parameters
539 ----------
540 array : array_like of rank N
541 The array to pad.
542 pad_width : {sequence, array_like, int}
543 Number of values padded to the edges of each axis.
544 ``((before_1, after_1), ... (before_N, after_N))`` unique pad widths
545 for each axis.
546 ``(before, after)`` or ``((before, after),)`` yields same before
547 and after pad for each axis.
548 ``(pad,)`` or ``int`` is a shortcut for before = after = pad width
549 for all axes.
550 mode : str or function, optional
551 One of the following string values or a user supplied function.
552
553 'constant' (default)
554 Pads with a constant value.
555 'edge'
556 Pads with the edge values of array.
557 'linear_ramp'
558 Pads with the linear ramp between end_value and the
559 array edge value.
560 'maximum'
561 Pads with the maximum value of all or part of the
562 vector along each axis.
563 'mean'
564 Pads with the mean value of all or part of the
565 vector along each axis.
566 'median'
567 Pads with the median value of all or part of the
568 vector along each axis.
569 'minimum'
570 Pads with the minimum value of all or part of the
571 vector along each axis.
572 'reflect'
573 Pads with the reflection of the vector mirrored on
574 the first and last values of the vector along each
575 axis.
576 'symmetric'
577 Pads with the reflection of the vector mirrored
578 along the edge of the array.
579 'wrap'
580 Pads with the wrap of the vector along the axis.
581 The first values are used to pad the end and the
582 end values are used to pad the beginning.
583 'empty'
584 Pads with undefined values.
585
586 .. versionadded:: 1.17
587
588 <function>
589 Padding function, see Notes.
590 stat_length : sequence or int, optional
591 Used in 'maximum', 'mean', 'median', and 'minimum'. Number of

Callers

nothing calls this directly

Calls 12

ndindexClass · 0.90
_as_pairsFunction · 0.85
_pad_simpleFunction · 0.85
_view_roiFunction · 0.85
_set_pad_areaFunction · 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
anyFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected