Skip to content

Skip generating source links for re-exported numpy functions in docs #28886

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

Merged
merged 1 commit into from
May 21, 2025

Conversation

dfm
Copy link
Contributor

@dfm dfm commented May 21, 2025

Fixes #28885

Some jnp functions (e.g. savez) link to non-existent URLs when they are re-exported from numpy. We can skip generating these links when the source file doesn't live under the jax source root.

At this change, the source link no longer appears for savez, but it does for linspace, for example.

@dfm dfm self-assigned this May 21, 2025
@nicholasjng
Copy link
Contributor

Looks good! Would it be possible to mark NumPy re-exports on their summary pages as such?

@dfm dfm requested a review from jakevdp May 21, 2025 15:07
@dfm
Copy link
Contributor Author

dfm commented May 21, 2025

Would it be possible to mark NumPy re-exports on their summary pages as such?

I'll let Jake comment on this one, but I agree that that would probably be a good idea!

@jakevdp
Copy link
Collaborator

jakevdp commented May 21, 2025

Looks good! Would it be possible to mark NumPy re-exports on their summary pages as such?

What summary pages do you have in mind?

@nicholasjng
Copy link
Contributor

Mostly the jax.numpy.save(z) function family, since I didn't quite catch that they are from NumPy, and started wondering about what they return. That's also why I posted the discussion that you kindly already answered (thanks!).

For instance, even on this PR branch, the docs on jnp.save reproduce the code examples from NumPy, with np. calls. Not that that's a bad thing per se, just maybe a bit unexpected.

@jakevdp
Copy link
Collaborator

jakevdp commented May 21, 2025

I see - we have a couple options here:

  1. don't list jnp.save on the JAX website
  2. create an explicit wrapper function for jnp.save with its own docstring
  3. do some kind of special-casing in the sphinx documentation build to mark aliased functions

I think (2) is probably the cleanest solution.

@jakevdp
Copy link
Collaborator

jakevdp commented May 21, 2025

Actually, there's also (4) deprecate jnp.save and jnp.savez, and suggest users use the NumPy versions directly.

I actually think this might be the clearest approach here.

@dfm
Copy link
Contributor Author

dfm commented May 21, 2025

This sounds good to me, but I don't think it makes sense to make this change here. I'd say that it's still worth merging this PR regardless because we shouldn't ever generate these broken URLs!

@google-ml-butler google-ml-butler bot added kokoro:force-run pull ready Ready for copybara import and testing labels May 21, 2025
@dfm
Copy link
Contributor Author

dfm commented May 21, 2025

I'm happy to add these deprecations in a follow up PR!

@copybara-service copybara-service bot merged commit fb4279a into jax-ml:main May 21, 2025
22 of 23 checks passed
@dfm dfm deleted the np-doc-links branch May 21, 2025 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation kokoro:force-run pull ready Ready for copybara import and testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

docs: Links to source code of numpy shims are broken
3 participants