Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@romanc
Copy link
Collaborator

@romanc romanc commented Aug 12, 2025

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 LegacyMetric calculation 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:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation: N/A
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules: N/A
  • New check tests, if applicable, are included: N/A

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.
@romanc
Copy link
Collaborator Author

romanc commented Aug 12, 2025

/cc @twicki as just debugged together.

Copy link
Collaborator

@twicki twicki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks

@romanc
Copy link
Collaborator Author

romanc commented Aug 13, 2025

@oelbert any concerns merging this?

@romanc romanc added this pull request to the merge queue Aug 14, 2025
Merged via the queue into NOAA-GFDL:develop with commit 6b54efd Aug 14, 2025
5 checks passed
@romanc romanc deleted the romanc/fix-nans-in-reference branch September 12, 2025 14:57
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.

2 participants