Skip to content

Commit ec24005

Browse files
author
jax authors
committed
Merge pull request #12334 from jakevdp:fix-ensure-index
PiperOrigin-RevId: 473961635
2 parents c491aaa + 45b71e5 commit ec24005

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

jax/_src/api_util.py

+2
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,15 @@
3737

3838
def _ensure_index(x: Any) -> Union[int, Tuple[int, ...]]:
3939
"""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.")
4041
try:
4142
return operator.index(x)
4243
except TypeError:
4344
return tuple(map(operator.index, x))
4445

4546
def _ensure_index_tuple(x: Any) -> Tuple[int, ...]:
4647
"""Convert x to a tuple of indices."""
48+
x = core.concrete_or_error(None, x, "expected a static index or sequence of indices.")
4749
try:
4850
return (operator.index(x),)
4951
except TypeError:

0 commit comments

Comments
 (0)