We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents c491aaa + 45b71e5 commit ec24005Copy full SHA for ec24005
jax/_src/api_util.py
@@ -37,13 +37,15 @@
37
38
def _ensure_index(x: Any) -> Union[int, Tuple[int, ...]]:
39
"""Ensure x is either an index or a tuple of indices."""
40
+ x = core.concrete_or_error(None, x, "expected a static index or sequence of indices.")
41
try:
42
return operator.index(x)
43
except TypeError:
44
return tuple(map(operator.index, x))
45
46
def _ensure_index_tuple(x: Any) -> Tuple[int, ...]:
47
"""Convert x to a tuple of indices."""
48
49
50
return (operator.index(x),)
51
0 commit comments