Skip to content

Commit c211ae7

Browse files
authored
fix: import concrete_or_error from jax.extend.core on JAX>=0.11 (#871)
jax.core.concrete_or_error was removed in JAX 0.11 (deprecated in 0.10); use jax.extend.core.concrete_or_error with a fallback to jax.core for JAX <0.10.
1 parent edd1e8e commit c211ae7

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

brainpy/math/activations.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,11 @@
3434

3535
from .ndarray import Array
3636

37+
try:
38+
from jax.extend.core import concrete_or_error
39+
except ImportError: # JAX < 0.10 exposes it only on jax.core
40+
from jax.core import concrete_or_error
41+
3742
__all__ = [
3843
'celu',
3944
'elu',
@@ -466,7 +471,7 @@ def one_hot(x, num_classes, *, dtype=None, axis=-1):
466471
the axis or axes along which the function should be
467472
computed.
468473
"""
469-
num_classes = jax.core.concrete_or_error(
474+
num_classes = concrete_or_error(
470475
int, num_classes, "The error arose in jax.nn.one_hot argument `num_classes`.")
471476
dtype = jax.dtypes.canonicalize_dtype(jnp.float64 if dtype is None else dtype)
472477
x = jnp.asarray(x.value if isinstance(x, Array) else x)

0 commit comments

Comments
 (0)