Repository navigation
Conversation
The sine argument used (2i-1)p/M instead of (2i-1)p/(2M), which made the weights antisymmetric so they summed to about zero. The weights were also scaled by the alternative volume instead of the grid volume.
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #349
UniformGridwithweight="Fourier2"gave weights that summed to about zero, so every integral came out near 0 (e.g. a Gaussian that should givepi**1.5gave ~1e-16). In_fourier2the sine argument used(2i - 1) p / Mwhere the rectangle rule for sine series has(2i - 1) p / (2M), and the weights were scaled by the alternative volume(M - 1) hper axis instead of the grid volumeM h.Changes:
cubic.py: divide by2 * shape[index]in the Fourier2 sine argument, scale by_calculate_volumeinstead of_calculate_alternative_volume, and fix the Fourier2 formula in the docstring to match.test_cubic.py:test_fourier2_weights_are_correcthad the same missing factor and volume, so I updated it to the corrected formula, and addedtest_fourier2_weights_integrate_gaussian, which integratesexp(-r^2)on a 21^3 grid over [-5, 5]^3 and compares withpi**1.5.Testing:
pytest src/grid/tests/test_cubic.pypasses (33 passed).I used Claude to help find the bug and draft the test; I reviewed the change and ran the tests myself.