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

Fix the shapes of 2d filters #2390

Merged
merged 8 commits into from
Feb 9, 2023
Merged

Conversation

mawc2019
Copy link
Contributor

@mawc2019 mawc2019 commented Feb 3, 2023

As mentioned here, the 2d filters in filters.py should have kernels with circular boundaries, but these boundaries are rectangular in the current master branch. This PR makes them circular. In addition, this PR adds a round operation preceding each int operation in filters.py to avoid unexpected results, as mentioned here.

@oskooi
Copy link
Collaborator

oskooi commented Feb 3, 2023

The pre-commit check is failing which likely means you forgot to first install the pre-commit package.

See: https://meep.readthedocs.io/en/latest/Build_From_Source/#meep-for-developers

@codecov-commenter
Copy link

codecov-commenter commented Feb 3, 2023

Codecov Report

Merging #2390 (383babf) into master (b86b476) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more

@@            Coverage Diff             @@
##           master    #2390      +/-   ##
==========================================
- Coverage   72.57%   72.56%   -0.01%     
==========================================
  Files          17       17              
  Lines        5166     5165       -1     
==========================================
- Hits         3749     3748       -1     
  Misses       1417     1417              
Impacted Files Coverage Δ
python/adjoint/filters.py 60.58% <100.00%> (-0.29%) ⬇️

@mawc2019
Copy link
Contributor Author

mawc2019 commented Feb 4, 2023

I just installed the pre-commit and committed again, but this online pre-commit check still fails. Does the pre-commit check run automatically when I do git commit on a branch, or should I somehow run it manually?

@mawc2019
Copy link
Contributor Author

mawc2019 commented Feb 4, 2023

The error in the failed test is as follows.

Traceback (most recent call last):
  File "/home/runner/work/meep/meep/build/meep-1.26.0-beta/_build/sub/python/../../../python/tests/test_adjoint_solver.py", line 685, in test_gradient_backpropagation
    self.assertClose(adj_dd, fnd_dd, epsilon=tol)
  File "/home/runner/work/meep/meep/build/meep-1.26.0-beta/python/tests/utils.py", line 30, in assertClose
    self.assertLessEqual(diff_norm, epsilon * np.maximum(x_norm, y_norm), msg)
AssertionError: 9.003547633008868e-06 not less than or equal to 8.717597578845472e-06 :

This error is related to the code below when single precision is used.

            if nfrq == 1 and frequencies[0] == self.fcen:
                tol = 2e-4 if mp.is_single_precision() else 5e-6

Increasing the tolerance tol from 2e-4 to 2.1e-4 would resolve the issue. Shall we do this?

@stevengj
Copy link
Collaborator

stevengj commented Feb 5, 2023

Sure, a 5% increase in the tolerance is fine.

@stevengj
Copy link
Collaborator

stevengj commented Feb 9, 2023

LGTM!

python/adjoint/filters.py Outdated Show resolved Hide resolved
python/adjoint/filters.py Outdated Show resolved Hide resolved
@stevengj stevengj merged commit 3eb4026 into NanoComp:master Feb 9, 2023
@stevengj
Copy link
Collaborator

stevengj commented Feb 9, 2023

When you get a chance, try re-running the tutorials so that we can update the images (which will presumably change slightly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants