Feature/zeroth mesh edge#58
Merged
Merged
Conversation
rhayes777
approved these changes
Mar 24, 2023
Comment on lines
+204
to
+228
| def test__brightness_zeroth_regularization_weights_from(): | ||
|
|
||
| pixel_signals = np.array([1.0, 1.0, 1.0]) | ||
|
|
||
| weight_list = aa.util.regularization.brightness_zeroth_regularization_weights_from( | ||
| coefficient=1.0, pixel_signals=pixel_signals | ||
| ) | ||
|
|
||
| assert (weight_list == np.array([0.0, 0.0, 0.0])).all() | ||
|
|
||
| pixel_signals = np.array([0.25, 0.5, 0.75]) | ||
|
|
||
| weight_list = aa.util.regularization.brightness_zeroth_regularization_weights_from( | ||
| coefficient=1.0, pixel_signals=pixel_signals | ||
| ) | ||
|
|
||
| assert (weight_list == np.array([0.75, 0.5, 0.25])).all() | ||
|
|
||
| pixel_signals = np.array([0.25, 0.5, 0.75]) | ||
|
|
||
| weight_list = aa.util.regularization.brightness_zeroth_regularization_weights_from( | ||
| coefficient=2.0, pixel_signals=pixel_signals | ||
| ) | ||
|
|
||
| assert (weight_list == np.array([1.5, 1.0, 0.5])).all() |
Comment on lines
+517
to
+541
| def test__brightness_zeroth_regularization_matrix_from(): | ||
|
|
||
| regularization_weights = np.ones(shape=(3,)) | ||
|
|
||
| regularization_matrix = ( | ||
| aa.util.regularization.brightness_zeroth_regularization_matrix_from( | ||
| regularization_weights=regularization_weights, | ||
| ) | ||
| ) | ||
|
|
||
| assert regularization_matrix == pytest.approx( | ||
| np.array([[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]), 1.0e-4 | ||
| ) | ||
|
|
||
| regularization_weights = np.array([1.0, 2.0, 3.0]) | ||
|
|
||
| regularization_matrix = ( | ||
| aa.util.regularization.brightness_zeroth_regularization_matrix_from( | ||
| regularization_weights=regularization_weights, | ||
| ) | ||
| ) | ||
|
|
||
| assert regularization_matrix == pytest.approx( | ||
| np.array([[1.0, 0.0, 0.0], [0.0, 4.0, 0.0], [0.0, 0.0, 9.0]]), 1.0e-4 | ||
| ) |
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.
An experimental regularization scheme which applies adaptive zeroth-order regularization to the exterior regions of a inversion mesh (e.g. the regions of the source-plane that dont contain the source).
If this works, we will want to adjust PyAutoFit to allow a galaxy object to have multiple regularization schemes, which each lead to the summation of their regularization matrices.