Parse broadcast and core dimensions for vectorize with a signature. Arguments --------- args : Tuple[ndarray, ...] Tuple of input arguments to examine. input_core_dims : List[Tuple[str, ...]] List of core dimensions corresponding to each input. Returns
(args, input_core_dims)
| 2064 | |
| 2065 | |
| 2066 | def _parse_input_dimensions(args, input_core_dims): |
| 2067 | """ |
| 2068 | Parse broadcast and core dimensions for vectorize with a signature. |
| 2069 | |
| 2070 | Arguments |
| 2071 | --------- |
| 2072 | args : Tuple[ndarray, ...] |
| 2073 | Tuple of input arguments to examine. |
| 2074 | input_core_dims : List[Tuple[str, ...]] |
| 2075 | List of core dimensions corresponding to each input. |
| 2076 | |
| 2077 | Returns |
| 2078 | ------- |
| 2079 | broadcast_shape : Tuple[int, ...] |
| 2080 | Common shape to broadcast all non-core dimensions to. |
| 2081 | dim_sizes : Dict[str, int] |
| 2082 | Common sizes for named core dimensions. |
| 2083 | """ |
| 2084 | broadcast_args = [] |
| 2085 | dim_sizes = {} |
| 2086 | for arg, core_dims in zip(args, input_core_dims): |
| 2087 | _update_dim_sizes(dim_sizes, arg, core_dims) |
| 2088 | ndim = arg.ndim - len(core_dims) |
| 2089 | dummy_array = np.lib.stride_tricks.as_strided(0, arg.shape[:ndim]) |
| 2090 | broadcast_args.append(dummy_array) |
| 2091 | broadcast_shape = np.lib.stride_tricks._broadcast_shape(*broadcast_args) |
| 2092 | return broadcast_shape, dim_sizes |
| 2093 | |
| 2094 | |
| 2095 | def _calculate_shapes(broadcast_shape, dim_sizes, list_of_core_dims): |
no test coverage detected