| 1227 | return result |
| 1228 | |
| 1229 | def _pad_options_dim_to_index( |
| 1230 | self, |
| 1231 | pad_option: Mapping[Any, int | float | tuple[int, int] | tuple[float, float]], |
| 1232 | fill_with_shape=False, |
| 1233 | ): |
| 1234 | # change number values to a tuple of two of those values |
| 1235 | for k, v in pad_option.items(): |
| 1236 | if isinstance(v, numbers.Number): |
| 1237 | pad_option[k] = (v, v) |
| 1238 | |
| 1239 | if fill_with_shape: |
| 1240 | return [ |
| 1241 | pad_option.get(d, (n, n)) |
| 1242 | for d, n in zip(self.dims, self.shape, strict=True) |
| 1243 | ] |
| 1244 | return [pad_option.get(d, (0, 0)) for d in self.dims] |
| 1245 | |
| 1246 | def pad( |
| 1247 | self, |