Returns the shape of the arrays that would result from broadcasting the supplied arrays against each other.
(*args)
| 518 | |
| 519 | |
| 520 | def _broadcast_shape(*args): |
| 521 | """Returns the shape of the arrays that would result from broadcasting the |
| 522 | supplied arrays against each other. |
| 523 | """ |
| 524 | # use the old-iterator because np.nditer does not handle size 0 arrays |
| 525 | # consistently |
| 526 | b = np.broadcast(*args[:64]) |
| 527 | # unfortunately, it cannot handle 64 or more arguments directly |
| 528 | for pos in range(64, len(args), 63): |
| 529 | # ironically, np.broadcast does not properly handle np.broadcast |
| 530 | # objects (it treats them as scalars) |
| 531 | # use broadcasting to avoid allocating the full array |
| 532 | b = broadcast_to(0, b.shape) |
| 533 | b = np.broadcast(b, *args[pos:(pos + 63)]) |
| 534 | return b.shape |
| 535 | |
| 536 | |
| 537 | _size0_dtype = np.dtype([]) |
searching dependent graphs…