tests: fix NaNs introduced into reference values#199
Merged
Conversation
PR NOAA-GFDL#74 introduced better comparison in the `LegacyMetric`. Unfortunately, this overrides the reference values under certain conditions. The regression was realized because NaNs were copied into the reference values where 0 was expected. This PR fixes the LegacyMetric to copy the reference data before manipulating the array to avoid devision by 0 errors. In case the reference value is 0 (and thus the denominater would be 0), we set the denominator to 1 because we expect the computed value to be (close to) 0. In that case (abs(computed - expected) / 1.0) is a good value for the error being reported.
Collaborator
Author
|
/cc @twicki as just debugged together. |
Collaborator
Author
|
@oelbert any concerns merging this? |
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.
Description
PR #74 introduced better comparison in the
LegacyMetric. Unfortunately, this overrides the reference values under certain conditions. The regression was realized because NaNs were copied into the reference values where 0 was expected.This PR fixes the
LegacyMetriccalculation to copy the reference data before manipulating the array to avoid devision by 0 errors. In case the reference value is 0 (and thus the denominater would be 0), we set the denominator to 1 because we expect the computed value to be (close to) 0. In that case (abs(computed - expected) / 1.0) is a good value for the error being reported.How Has This Been Tested?
Running tests locally.
Checklist: