Given any number of variables, return variables with matching dimensions and broadcast data. The data on the returned variables will be a view of the data on the corresponding original arrays, but dimensions will be reordered and inserted so that both broadcast arrays have the same
(*variables: Variable)
| 3038 | |
| 3039 | |
| 3040 | def broadcast_variables(*variables: Variable) -> tuple[Variable, ...]: |
| 3041 | """Given any number of variables, return variables with matching dimensions |
| 3042 | and broadcast data. |
| 3043 | |
| 3044 | The data on the returned variables will be a view of the data on the |
| 3045 | corresponding original arrays, but dimensions will be reordered and |
| 3046 | inserted so that both broadcast arrays have the same dimensions. The new |
| 3047 | dimensions are sorted in order of appearance in the first variable's |
| 3048 | dimensions followed by the second variable's dimensions. |
| 3049 | """ |
| 3050 | dims_map = _unified_dims(variables) |
| 3051 | dims_tuple = tuple(dims_map) |
| 3052 | return tuple( |
| 3053 | var.set_dims(dims_map) if var.dims != dims_tuple else var for var in variables |
| 3054 | ) |
| 3055 | |
| 3056 | |
| 3057 | def _broadcast_compat_data(self, other): |
no test coverage detected
searching dependent graphs…