Expands the ellipsis at the start of `key_list`. Assumes that the first element of `key_list` is Ellipsis. This will either remove the Ellipsis (if it corresponds to zero indices) or prepend a new `slice(None, None, None)` (if it corresponds to more than zero indices). Args: key_list:
(key_list, num_remaining_dims)
| 286 | |
| 287 | |
| 288 | def _expand_ellipsis(key_list, num_remaining_dims): |
| 289 | """Expands the ellipsis at the start of `key_list`. |
| 290 | |
| 291 | Assumes that the first element of `key_list` is Ellipsis. This will either |
| 292 | remove the Ellipsis (if it corresponds to zero indices) or prepend a new |
| 293 | `slice(None, None, None)` (if it corresponds to more than zero indices). |
| 294 | |
| 295 | Args: |
| 296 | key_list: The arguments to `__getitem__()`. |
| 297 | num_remaining_dims: The number of dimensions remaining. |
| 298 | |
| 299 | Returns: |
| 300 | A copy of `key_list` with he ellipsis expanded. |
| 301 | Raises: |
| 302 | ValueError: If ragged_rank.shape.ndims is None |
| 303 | IndexError: If there are too many elements in `key_list`. |
| 304 | """ |
| 305 | if num_remaining_dims is None: |
| 306 | raise ValueError("Ellipsis not supported for unknown shape RaggedTensors") |
| 307 | num_indices = sum(1 for idx in key_list if idx is not array_ops.newaxis) |
| 308 | if num_indices > num_remaining_dims + 1: |
| 309 | raise IndexError("Too many indices for RaggedTensor") |
| 310 | elif num_indices == num_remaining_dims + 1: |
| 311 | return key_list[1:] |
| 312 | else: |
| 313 | return [slice(None, None, None)] + key_list |
| 314 | |
| 315 | |
| 316 | def _tensors_in_key_list(key_list): |
no test coverage detected