-
Notifications
You must be signed in to change notification settings - Fork 41
Replace finufft's warning with ours #1944
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
Open
unalmis
wants to merge
2
commits into
master
Choose a base branch
from
ku/more_warning
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| """Various checks to automate installation issues and decrease user support requests. | ||
|
|
||
| These tests run when DESC boots to notify users of potential issues | ||
| or to replace warning messages in downstream libraries with more | ||
| verbose warnings. | ||
| """ | ||
|
|
||
| import warnings | ||
|
|
||
| import numpy as np | ||
| from jax import grad | ||
|
|
||
| from desc.backend import jnp, rfft | ||
| from desc.integrals._interp_utils import nufft1d2r | ||
|
|
||
|
|
||
| def _c_1d(x): | ||
| return jnp.cos(7 * x) + jnp.sin(x) - 33.2 | ||
|
|
||
|
|
||
| @grad | ||
| def _true_g_c_1d(xq): | ||
| return _c_1d(xq).sum() | ||
|
|
||
|
|
||
| def check_jax_finufft(func=_c_1d, g_func=_true_g_c_1d): | ||
| """Runs tests/test_interp_utils.py::TestFastInterp::test_non_uniform_real_FFT.""" | ||
| n = 15 | ||
| f = 2 * rfft(func(jnp.linspace(0, 2 * jnp.pi, n, endpoint=False)), norm="forward") | ||
| f = f.at[..., (0, -1) if (n % 2 == 0) else 0].divide(2) | ||
| xq = jnp.array([7.34, 1.10134, 2.28]) | ||
|
|
||
| msg = ( | ||
| "If you want to use NUFFTs, follow the DESC installation instructions.\n" | ||
| "Otherwise you must pass the parameter nufft_eps=0.\n" | ||
| "This applies to effective ripple, Gamma_c, and any other\n" | ||
| "computations that involve bounce integrals.\n" | ||
| ) | ||
| # https://github.com/unalmis/jax-finufft/blob/main/tests/interpolation_test.py#L13 | ||
| RTOL = 2e-6 | ||
|
|
||
| try: | ||
| np.testing.assert_allclose(nufft1d2r(xq, f), func(xq), rtol=RTOL) | ||
|
|
||
| @grad | ||
| def g(xq): | ||
| return nufft1d2r(xq, f, eps=1e-7).sum() | ||
|
|
||
| np.testing.assert_allclose(g(xq), g_func(xq), rtol=RTOL) | ||
| except NameError: | ||
| warnings.warn("\njax-finufft is not installed.\n" + msg) | ||
| except NotImplementedError: | ||
| warnings.warn("\njax-finufft is not installed on GPU.\n" + msg) | ||
| except AssertionError as e: | ||
| import jax_finufft | ||
|
|
||
| warnings.warn( | ||
| f"\njax-finufft version <= {jax_finufft.__version__} has incorrect maths.\n" | ||
| + "\n\n" | ||
| + e | ||
| + "\n\n" | ||
| + msg | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.