Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[array api] fix deprecation to support old import pattern #22825

Merged
merged 1 commit into from
Aug 1, 2024

Conversation

jakevdp
Copy link
Collaborator

@jakevdp jakevdp commented Aug 1, 2024

Followup to #22818

The previous approach made it so that a common import pattern didn't work:

>>> import jax.experimental.array_api as nx
ModuleNotFoundError: No module named 'jax.experimental.array_api'

We need to keep a stub submodule here, but patch sys.modules to return the new path. With this change, it looks like this:

In [1]: import jax.experimental.array_api as nx
<ipython-input-1-9d2abc00e9fa>:1: DeprecationWarning: jax.experimental.array_api import is no longer required as of JAX v0.4.32; jax.numpy supports the array API by default.
  import jax.experimental.array_api as nx

In [2]: import jax.numpy as jnp

In [3]: nx is jnp
Out[3]: True

@jakevdp jakevdp self-assigned this Aug 1, 2024
@jakevdp jakevdp added the pull ready Ready for copybara import and testing label Aug 1, 2024
@jakevdp jakevdp requested a review from froystig August 1, 2024 21:27
@jakevdp
Copy link
Collaborator Author

jakevdp commented Aug 1, 2024

I also tested this locally with both the released version of array_api_compat and with data-apis/array-api-compat#172, and it works correctly in both cases.

@copybara-service copybara-service bot merged commit 16c868a into jax-ml:main Aug 1, 2024
15 checks passed
@jakevdp jakevdp deleted the fix-old-array-api branch August 1, 2024 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull ready Ready for copybara import and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants