Closed mawc2019 closed 1 year ago
Check out this pull request on
See visual diffs & provide feedback on Jupyter Notebooks.
Powered by ReviewNB
Merging #2504 (0d73d36) into master (79e8d17) will not change coverage. The diff coverage is
100.00%
.
:mega: 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 #2504 +/- ##
=======================================
Coverage 73.92% 73.92%
=======================================
Files 18 18
Lines 5296 5296
=======================================
Hits 3915 3915
Misses 1381 1381
Impacted Files | Coverage Δ | |
---|---|---|
python/adjoint/filters.py | 79.89% <100.00%> (ø) |
We need to increase some tolerances in test_adjoint_solver.py
.
Python 3.7:
FAIL: test_eigenmode (__main__.TestAdjointSolver)
Verifies that the adjoint gradient for an objective function based
----------------------------------------------------------------------
Traceback (most recent call last):
File "../../../python/tests/test_adjoint_solver.py", line 592, in test_eigenmode
self.assertClose(adj_dd, fnd_dd, epsilon=tol)
File "/home/runner/work/meep/meep/build/meep-1.27.0-beta/python/tests/utils.py", line 30, in assertClose
self.assertLessEqual(diff_norm, epsilon * np.maximum(x_norm, y_norm), msg)
AssertionError: 2.4692787936065122e-05 not less than or equal to 2.147141650190434e-05 :
======================================================================
FAIL: test_ldos (__main__.TestAdjointSolver)
Verifies that the adjoint gradient for an objective function based
----------------------------------------------------------------------
Traceback (most recent call last):
File "../../../python/tests/test_adjoint_solver.py", line 621, in test_ldos
self.assertClose(adj_dd, fnd_dd, epsilon=tol)
File "/home/runner/work/meep/meep/build/meep-1.27.0-beta/python/tests/utils.py", line 30, in assertClose
self.assertLessEqual(diff_norm, epsilon * np.maximum(x_norm, y_norm), msg)
AssertionError: 1.866014771444676e-10 not less than or equal to 7.504694841953264e-11 :
Python 3.10:
FAIL: test_DFT_fields (__main__.TestAdjointSolver)
Verifies that the adjoint gradient for an objective function based
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/work/meep/meep/build/meep-1.27.0-beta/_build/sub/python/../../../python/tests/test_adjoint_solver.py", line 551, in test_DFT_fields
self.assertClose(adj_dd, fnd_dd, epsilon=tol)
File "/home/runner/work/meep/meep/build/meep-1.27.0-beta/python/tests/utils.py", line 30, in assertClose
self.assertLessEqual(diff_norm, epsilon * np.maximum(x_norm, y_norm), msg)
AssertionError: 0.00032576555598241895 not less than or equal to 0.00015930181276331502 :
======================================================================
FAIL: test_eigenmode (__main__.TestAdjointSolver)
Verifies that the adjoint gradient for an objective function based
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/work/meep/meep/build/meep-1.27.0-beta/_build/sub/python/../../../python/tests/test_adjoint_solver.py", line 592, in test_eigenmode
self.assertClose(adj_dd, fnd_dd, epsilon=tol)
File "/home/runner/work/meep/meep/build/meep-1.27.0-beta/python/tests/utils.py", line 30, in assertClose
self.assertLessEqual(diff_norm, epsilon * np.maximum(x_norm, y_norm), msg)
AssertionError: 6.287598863467803e-05 not less than or equal to 3.214987858228824e-05 :
======================================================================
FAIL: test_ldos (__main__.TestAdjointSolver)
Verifies that the adjoint gradient for an objective function based
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/runner/work/meep/meep/build/meep-1.27.0-beta/_build/sub/python/../../../python/tests/test_adjoint_solver.py", line 621, in test_ldos
self.assertClose(adj_dd, fnd_dd, epsilon=tol)
File "/home/runner/work/meep/meep/build/meep-1.27.0-beta/python/tests/utils.py", line 30, in assertClose
self.assertLessEqual(diff_norm, epsilon * np.maximum(x_norm, y_norm), msg)
AssertionError: 2.0344705001442236e-10 not less than or equal to 1.5012644966061473e-10 :
The test in test_unfilter_design
also fails due to mismatch of array size.
ValueError: cannot reshape array of size 160000 into shape (401,401)
A factor of ≈2 increase in the tolerances seems fine.
Looks like the error tolerances in test_adjoint_solver.py
need to be reverted to (close to) what they were in #1769.
Looks like the error tolerances in test_adjoint_solver.py need to be reverted to (close to) what they were in https://github.com/NanoComp/meep/pull/1769.
We probably cannot do so because frequency widths are quite different in the two cases. Now there is df = 0.05*fcen
, but in #1769 there was df = 0.23*fcen
. The values of gradients and hence the tolerances are not comparable between the two cases.
In addition, it seems that +1
is also needed in the expressions of Nr
and Nz
in test_adjoint_cyl.py
.
Nr, Nz = int(design_r * design_region_resolution), int(design_z * design_region_resolution)
The missing +1 in the array size of the material grid is restored in this PR, but some tests in test_adjoint_solver.py fail.