bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / _external / array_api_extra / _delegation / broadcast_shapes
function
scipy._external.array_api_extra._delegation:broadcast_shapes
source: build-install/usr/lib/python3.14/site-packages/scipy/_external/array_api_extra/_delegation.py:108
Signature
def broadcast_shapes(*shapes: tuple[float | None, ...], xp: ArrayNamespace | None = None) → tuple[int | None, ...]Summary
Compute the shape of the broadcasted arrays.
Extended Summary
Duplicates numpy.broadcast_shapes, with additional support for None and NaN sizes.
Parameters
*shapes: tuple[int | None, ...]Shapes of the arrays to broadcast.
xp: array_namespace, optionalThe standard-compatible namespace to use for native delegation. Default: use the array-agnostic implementation.
Returns
: tuple[int | None, ...]The shape of the broadcasted arrays.
Notes
This function accepts the Array API's None for unknown sizes, as well as Dask's non-standard math.nan. Regardless of input, the output always contains None for unknown sizes.
Examples
import array_api_extra as xpx xpx.broadcast_shapes((2, 3), (2, 1)) xpx.broadcast_shapes((4, 2, 3), (2, 1), (1, 3))⚠
Traceback (most recent call last):
File "<doctest scipy._external.array_api_extra._delegation:broadcast_shapes[0]>", line 1, in <module>
xpx.broadcast_shapes((4, 2, 3), (2, 1), (1, 3))
^^^
NameError: name 'xpx' is not defined
See also
- array_api.broadcast_arrays
Function to broadcast actual arrays.
- numpy.broadcast_shapes
Equivalent NumPy function.
Aliases
scipy.differentiate.xpx.broadcast_shapes