-
Notifications
You must be signed in to change notification settings - Fork 154
Fix seeding with undefined elements #743
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -279,4 +279,33 @@ end | |
| end | ||
| end | ||
|
|
||
| # issues #436, #740 | ||
| @testset "BigFloat" begin | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this test cover all the new branches? It seems CodeCov is sleeping at the wheel.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codecov results are available on the codecov webpage: https://app.codecov.io/github/JuliaDiff/ForwardDiff.jl/commit/6f8f6a977d4d69fda7c492f6e0a47cb8a6853045 (I assume the codecov app is not installed in the repo and hence there's no nice summary in the PR - AFAICT I don't have sufficient permissions to install it) Indeed, you were right, the tests did not cover all new branches. I extended the tests, and locally it seems that they cover all branches as commenting out any of the branches leads to test failures.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codecov confirms that all modified lines are covered by the tests: https://app.codecov.io/github/JuliaDiff/ForwardDiff.jl/commit/ec3e483747159b46e0db5328c60c3543c13478a6/indirect-changes |
||
| # Unassigned entries in the output | ||
| x = BigFloat.(1:9) | ||
| for chunksize in (1, 2, 9) | ||
| y = similar(x) | ||
| @test all(i -> !isassigned(y, i), eachindex(y)) | ||
| cfg = ForwardDiff.JacobianConfig(copyto!, y, x, ForwardDiff.Chunk{chunksize}()) | ||
| res = ForwardDiff.jacobian(copyto!, y, x, cfg) | ||
| @test y == x | ||
| @test res isa Matrix{BigFloat} | ||
| @test res == I | ||
| end | ||
|
|
||
| # Unassigned (but unused) entry in the input and unassigned entries in the output | ||
| resize!(x, 10) | ||
| f = (y, x) -> copyto!(y, 1, x, 1, 9) | ||
| for chunksize in (1, 2, 10) | ||
| y = similar(x, 9) | ||
| @test all(i -> !isassigned(y, i), eachindex(y)) | ||
| cfg = ForwardDiff.JacobianConfig(f, y, x, ForwardDiff.Chunk{chunksize}()) | ||
| res = ForwardDiff.jacobian(f, y, x, cfg) | ||
| @test y == x[1:(end-1)] | ||
| @test res isa Matrix{BigFloat} | ||
| @test res[:, 1:(end-1)] == I | ||
| @test all(iszero, res[:, end]) | ||
| end | ||
| end | ||
|
|
||
| end # module | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:/, this is quite unfortunate, is this really the only way to fix this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the idea is that if
x[idx]is#undef, we wantduals[idx]to be the sameThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I wasn't 100% percent happy but it was the best I could think of and what apparently is used in base. IMO we really want to ensure here that we get the same behaviour as
copyto!on the primal part, to avoid thatydualscontains any surprising values, possibly from previous chunks or differentations.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.