Better suppotr for incomplete JAX installations. Supersedes #105.

This commit is contained in:
Patrick Kidger
2023-09-14 20:13:06 -07:00
parent c80c1264d3
commit d2785baced
2 changed files with 6 additions and 10 deletions
+1 -9
View File
@@ -20,20 +20,12 @@
import importlib.metadata
import typing
try:
import jax
except ImportError:
has_jax = False
else:
has_jax = True
del jax
# First import some things as normal
from ._array_types import (
AbstractArray as AbstractArray,
AbstractDtype as AbstractDtype,
get_array_name_format as get_array_name_format,
has_jax,
set_array_name_format as set_array_name_format,
)
from ._decorator import jaxtyped as jaxtyped
+5 -1
View File
@@ -32,7 +32,11 @@ from ._decorator import storage
try:
import jax
except ImportError:
except (ImportError, RuntimeError, AttributeError):
# We catch `RuntimeError` as JAX will throw this if it's present, but unable to run
# on the current machine. This fails with this error.
# We catch `AttributeError` as the above then leaves the module in a partially
# initialised state, which causes subsequent imports to fail with this error.
has_jax = False
else:
has_jax = True