Skip to content

Conversation

@jClugstor
Copy link
Contributor

Currently an example like this:

using ForwardDiff
using NaNMath

function new_pow(x)
    NaNMath.pow(x[1],x[2])
end

ForwardDiff.gradient(new_pow, [-1.0, 2.0])

errors. I'd like to make it so that it returns a NaN instead.

Fixes #716

@codecov
Copy link

codecov bot commented Nov 1, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.75%. Comparing base (c310fb5) to head (db4d9f9).
Report is 11 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #717      +/-   ##
==========================================
- Coverage   89.57%   86.75%   -2.83%     
==========================================
  Files          11       10       -1     
  Lines         969      921      -48     
==========================================
- Hits          868      799      -69     
- Misses        101      122      +21     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mcabbott
Copy link
Member

mcabbott commented Nov 1, 2024

Can you add a few cases to the tests? Ideally NaN/not/negative through both paths.

Co-authored-by: David Widmann <[email protected]>
@mcabbott mcabbott merged commit 8eaba05 into JuliaDiff:master Nov 8, 2024
4 of 6 checks passed
devmotion added a commit that referenced this pull request Nov 8, 2024
* fix NaNMath exponentiation

* reuse code

* fix

* add tests

* Update src/dual.jl

Co-authored-by: David Widmann <[email protected]>

* import NaNMath

* oops, no begin

* Update test/GradientTest.jl

Co-authored-by: David Widmann <[email protected]>

---------

Co-authored-by: David Widmann <[email protected]>
@devmotion devmotion mentioned this pull request Nov 8, 2024
devmotion added a commit that referenced this pull request Nov 8, 2024
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.

Implementation of Dual for NaNMath.pow does not use NaNMath.log

3 participants