Checks that `item` has a consistent shape matching `shape`.
(item, shape)
| 286 | return (0,) |
| 287 | |
| 288 | def check_inner_shape(item, shape): |
| 289 | """Checks that `item` has a consistent shape matching `shape`.""" |
| 290 | is_nested = isinstance(item, (list, tuple)) or np.ndim(item) != 0 |
| 291 | if is_nested != bool(shape): |
| 292 | raise ValueError("inner values have inconsistent shape") |
| 293 | if is_nested: |
| 294 | if shape[0] != len(item): |
| 295 | raise ValueError("inner values have inconsistent shape") |
| 296 | for child in item: |
| 297 | check_inner_shape(child, shape[1:]) |
| 298 | |
| 299 | # Collapse the ragged layers to get the list of inner values. |
| 300 | flat_values = pylist |
no test coverage detected