Returns the shape of the arrays that would result from broadcasting the supplied arrays against each other.
(*args)
| 414 | |
| 415 | |
| 416 | def _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') |