MCPcopy Index your code
hub / github.com/numpy/numpy / broadcast_shapes

Function broadcast_shapes

numpy/lib/_stride_tricks_impl.py:541–581  ·  view source on GitHub ↗

Broadcast the input shapes into a single shape. :ref:`Learn more about broadcasting here `. .. versionadded:: 1.20.0 Parameters ---------- *args : tuples of ints, or ints The shapes to be broadcast against each other. Returns -------

(*args)

Source from the content-addressed store, hash-verified

539
540@set_module('numpy')
541def broadcast_shapes(*args):
542 """
543 Broadcast the input shapes into a single shape.
544
545 :ref:`Learn more about broadcasting here <basics.broadcasting>`.
546
547 .. versionadded:: 1.20.0
548
549 Parameters
550 ----------
551 *args : tuples of ints, or ints
552 The shapes to be broadcast against each other.
553
554 Returns
555 -------
556 tuple
557 Broadcasted shape.
558
559 Raises
560 ------
561 ValueError
562 If the shapes are not compatible and cannot be broadcast according
563 to NumPy&#x27;s broadcasting rules.
564
565 See Also
566 --------
567 broadcast
568 broadcast_arrays
569 broadcast_to
570
571 Examples
572 --------
573 >>> import numpy as np
574 >>> np.broadcast_shapes((1, 2), (3, 1), (3, 2))
575 (3, 2)
576
577 >>> np.broadcast_shapes((6, 7), (5, 6, 1), (7,), (5, 1, 7))
578 (5, 6, 7)
579 """
580 arrays = [np.empty(x, dtype=_size0_dtype) for x in args]
581 return _broadcast_shape(*arrays)
582
583
584def _broadcast_arrays_dispatcher(*args, subok=None):

Callers 2

Calls 1

_broadcast_shapeFunction · 0.85

Tested by 2

Used in the wild real call sites across dependent graphs

searching dependent graphs…