This is a pre-release version (latest). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy latest / numpy / lib / _arraypad_impl / _as_pairs

function

numpy.lib._arraypad_impl:_as_pairs

source: build-install/usr/lib/python3.14/site-packages/numpy/lib/_arraypad_impl.py :471

Signature

def   _as_pairs ( x ndim as_index = False )

Summary

Broadcast x to an array with the shape (ndim, 2).

Extended Summary

A helper function for pad that prepares and validates arguments like pad_width for iteration in pairs.

Parameters

x : {None, scalar, array-like}

The object to broadcast to the shape (ndim, 2).

ndim : int

Number of pairs the broadcasted x will have.

as_index : bool, optional

If x is not None, try to round each element of x to an integer (dtype np.intp) and ensure every element is positive.

Returns

pairs : nested iterables, shape (`ndim`, 2)

The broadcasted version of x.

Raises

: ValueError

If as_index is True and x contains negative elements. Or if x is not broadcastable to the shape (ndim, 2).

Aliases

  • numpy.lib._arraypad_impl._as_pairs