Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

appends name of ad types used to ad test to failure output #2997

Merged
merged 3 commits into from
Jan 5, 2024

Conversation

SteveBronder
Copy link
Collaborator

Summary

When a test fails in the ad testing framework I always forget that the left hand side is the finite difference result and the right hand side is the autodiff result. This PR just adds a little line at the end of the test failure message for expect_near_rel that says what was used to get the gradients. An example is below where the error message is the same but has a little append for for {lhs_type} vs {rhs_type}.

./test/unit/math/expect_near_rel.hpp:33: Failure
The difference between x1 and x2 is 1, which exceeds tol_val, where
x1 evaluates to 1,
x2 evaluates to 2, and
tol_val evaluates to 0.00015000000000000001.
expect_near_rel_finite in: expect_near_rel; require items x1(0) = x2(0): hessian() grad for finite_diff vs fvar<var>

For a full example see the gist here for an example where I cause the add tests to fail.

Tests

No new tests since this just adds some words to the test message.

Side Effects

Nope

Release notes

Add helpful context to the failure message for the ad testing framework

Checklist

  • Copyright holder: Simons Foundation

    The copyright holder is typically you or your assignee, such as a university or company. By submitting this pull request, the copyright holder is agreeing to the license the submitted work under the following licenses:
    - Code: BSD 3-clause (https://opensource.org/licenses/BSD-3-Clause)
    - Documentation: CC-BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

  • the basic tests are passing

    • unit tests pass (to run, use: ./runTests.py test/unit)
    • header checks pass, (make test-headers)
    • dependencies checks pass, (make test-math-dependencies)
    • docs build, (make doxygen)
    • code passes the built in C++ standards checks (make cpplint)
  • the code is written in idiomatic C++ and changes are documented in the doxygen

  • the new changes are tested

Copy link
Member

@WardBrian WardBrian left a comment

Choose a reason for hiding this comment

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

Very useful!

Copy link
Member

@syclik syclik left a comment

Choose a reason for hiding this comment

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

Awesome!

@WardBrian WardBrian merged commit 0061d8f into develop Jan 5, 2024
8 checks passed
@WardBrian WardBrian deleted the fix/test-ad-names branch January 5, 2024 19:56
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.

5 participants