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

Function _broadcast_shape

numpy/lib/stride_tricks.py:416–430  ·  view source on GitHub ↗

Returns the shape of the arrays that would result from broadcasting the supplied arrays against each other.

(*args)

Source from the content-addressed store, hash-verified

414
415
416def _broadcast_shape(*args):
417 """Returns the shape of the arrays that would result from broadcasting the
418 supplied arrays against each other.
419 """
420 # use the old-iterator because np.nditer does not handle size 0 arrays
421 # consistently
422 b = np.broadcast(*args[:32])
423 # unfortunately, it cannot handle 32 or more arguments directly
424 for pos in range(32, len(args), 31):
425 # ironically, np.broadcast does not properly handle np.broadcast
426 # objects (it treats them as scalars)
427 # use broadcasting to avoid allocating the full array
428 b = broadcast_to(0, b.shape)
429 b = np.broadcast(b, *args[pos:(pos + 31)])
430 return b.shape
431
432
433@set_module('numpy')

Callers 3

test_broadcast_shapeFunction · 0.90
broadcast_shapesFunction · 0.85
broadcast_arraysFunction · 0.85

Calls 1

broadcast_toFunction · 0.70

Tested by 1

test_broadcast_shapeFunction · 0.72