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)
| 539 | |
| 540 | @set_module('numpy') |
| 541 | def 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'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 | |
| 584 | def _broadcast_arrays_dispatcher(*args, subok=None): |
searching dependent graphs…