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)
| 432 | |
| 433 | @set_module('numpy') |
| 434 | def broadcast_shapes(*args): |
| 435 | """ |
| 436 | Broadcast the input shapes into a single shape. |
| 437 | |
| 438 | :ref:`Learn more about broadcasting here <basics.broadcasting>`. |
| 439 | |
| 440 | .. versionadded:: 1.20.0 |
| 441 | |
| 442 | Parameters |
| 443 | ---------- |
| 444 | `*args` : tuples of ints, or ints |
| 445 | The shapes to be broadcast against each other. |
| 446 | |
| 447 | Returns |
| 448 | ------- |
| 449 | tuple |
| 450 | Broadcasted shape. |
| 451 | |
| 452 | Raises |
| 453 | ------ |
| 454 | ValueError |
| 455 | If the shapes are not compatible and cannot be broadcast according |
| 456 | to NumPy's broadcasting rules. |
| 457 | |
| 458 | See Also |
| 459 | -------- |
| 460 | broadcast |
| 461 | broadcast_arrays |
| 462 | broadcast_to |
| 463 | |
| 464 | Examples |
| 465 | -------- |
| 466 | >>> np.broadcast_shapes((1, 2), (3, 1), (3, 2)) |
| 467 | (3, 2) |
| 468 | |
| 469 | >>> np.broadcast_shapes((6, 7), (5, 6, 1), (7,), (5, 1, 7)) |
| 470 | (5, 6, 7) |
| 471 | """ |
| 472 | arrays = [np.empty(x, dtype=[]) for x in args] |
| 473 | return _broadcast_shape(*arrays) |
| 474 | |
| 475 | |
| 476 | def _broadcast_arrays_dispatcher(*args, subok=None): |