bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / _external / array_api_extra / _delegation / atleast_nd
function
scipy._external.array_api_extra._delegation:atleast_nd
source: build-install/usr/lib/python3.14/site-packages/scipy/_external/array_api_extra/_delegation.py:59
Signature
def atleast_nd(x: Array, /, ndim: int, xp: ArrayNamespace | None = None) → ArraySummary
Recursively expand the dimension of an array to at least ndim.
Parameters
x: arrayInput array.
ndim: intThe minimum number of dimensions for the result.
xp: array_namespace, optionalThe standard-compatible namespace for
x. Default: infer.
Returns
: arrayAn array with
res.ndim>=ndim. Ifx.ndim>=ndim,xis returned. Ifx.ndim<ndim,xis expanded by prepending new axes untilres.ndimequalsndim.
Examples
import array_api_strict as xp import array_api_extra as xpx x = xp.asarray([1]) xpx.atleast_nd(x, ndim=3, xp=xp)⚠
Traceback (most recent call last):
File "<doctest scipy._external.array_api_extra._delegation:atleast_nd[0]>", line 1, in <module>
xpx.atleast_nd(x, ndim=3, xp=xp)
^^^
NameError: name 'xpx' is not defined
x = xp.asarray([[[1, 2], [3, 4]]]) xpx.atleast_nd(x, ndim=1, xp=xp) is x⚠
Traceback (most recent call last):
File "<doctest scipy._external.array_api_extra._delegation:atleast_nd[0]>", line 1, in <module>
xpx.atleast_nd(x, ndim=1, xp=xp) is x
^^^
NameError: name 'xpx' is not defined
Aliases
scipy.differentiate.xpx.atleast_nd