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

improve type stability with StaticArrays #640

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

mapclyps
Copy link

Replace an anonymous function with Base.Fix1 for type stability in some cases, see #639

Replace an anonymous function with Base.Fix1 for type stability in some cases, see JuliaDiff#639
@codecov
Copy link

codecov bot commented Apr 19, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d300209) 89.65% compared to head (51d3d65) 87.28%.

❗ Current head 51d3d65 differs from pull request most recent head 02beae6. Consider uploading reports for the commit 02beae6 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #640      +/-   ##
==========================================
- Coverage   89.65%   87.28%   -2.38%     
==========================================
  Files          11       10       -1     
  Lines         967      912      -55     
==========================================
- Hits          867      796      -71     
- Misses        100      116      +16     

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

Copy link
Member

@devmotion devmotion left a comment

Choose a reason for hiding this comment

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

Thank you! Could you add a test for #639?

@mapclyps
Copy link
Author

I tried to replicate the type instability in the tests and put a test at the end of JacobianTest.jl like

ff(x) = sin.(x)
ssx = SA[1.0, 2.0]
ssy = ff(ssx)
result_store = DiffResults.JacobianResult(ssx)
@test begin
    result = (@inferred ForwardDiff.jacobian!(result_store, ff, ssx)) #the actual test
    jac = ForwardDiff.jacobian(ff, ssx)
    expected = DiffResults.ImmutableDiffResult(ssy, (jac,)) 
    result == expected
end

But to my surprise, there was no type instability with this test also on master.

However, just spinning up a REPL and executing this throws the error as expected and reported in #639.
Then I just moved this test to the top of the JacobianTest.jl file, and then it also threw the error on master (so it was working correctly as a test for the fix for #639). But it made me wonder what is actually going on there... and where this "hidden state" comes from.

Or is there a better, more stable way to test it?

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.

None yet

2 participants