Skip to content

Add testthat coverage for remaining numeric metrics #4032

Open
ayushman1210 wants to merge 2 commits into
PecanProject:developfrom
ayushman1210:gsoc/issue-4027
Open

Add testthat coverage for remaining numeric metrics #4032
ayushman1210 wants to merge 2 commits into
PecanProject:developfrom
ayushman1210:gsoc/issue-4027

Conversation

@ayushman1210

Copy link
Copy Markdown
Contributor

Description

Added 15 new unit tests in tests/testthat/test-numeric_metrics.R covering the following numeric metrics: metric_MSE, metric_AME, metric_PPMC, metric_RAE, and metric_Frechet.

For each of the 5 metrics, the test suite now explicitly verifies:

  1. Perfect Case: Asserts that error metrics return 0 and correlations return 1 when model perfectly matches obvs.
  2. NA Handling: Pins the internal behavior (na.rm, na.omit, pairwise.complete.obs) to ensure missing data is dropped cleanly without crashing the pipeline.
  3. Known Value Assertions: Validates the mathematical accuracy using hardcoded, hand-calculated datasets with deterministic outputs.

Note: The metric_Frechet tests are safely wrapped in a dependency check (skip_if_not_installed("SimilarityMeasures")) to ensure the CI build does not fail in minimal environments.

Motivation and Context

This PR adds comprehensive testthat coverage for the remaining numeric metrics in PEcAn.benchmark. This addresses the missing coverage for the error and distance metrics, satisfying a major requirement of the Phase 2 architecture rollout for my GSoC 2026 Validation Toolkit project.
Resolves #4027
Follow-up to PR #3888

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My change requires a change to the documentation.
  • My name is in the list of CITATION.cff
  • I agree that PEcAn Project may distribute my contribution under any or all of
    • the same license as the existing code,
    • and/or the BSD 3-clause license.
  • I have updated the CHANGELOG.md.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Review

Development

Successfully merging this pull request may close these issues.

add testthat coverage for remaining numeric metrics in PEcAn.benchmark

1 participant