Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #35 +/- ##
=======================================
Coverage 86.84% 86.84%
=======================================
Files 1 1
Lines 76 76
=======================================
Hits 66 66
Misses 10 10 ☔ View full report in Codecov by Sentry. |
Co-authored-by: David Widmann <devmotion@users.noreply.github.com>
|
How would you spot if there is one |
I'd define something like # It would be safer to use `false` as the default fallback...
ismutablearray(::AbstractArray) = true
ismutablearray(::SArray) = false
ismutablearray(::Diagonal{T,SMatrix{T}}) = false
...
DiffResult(value::Number, derivs::Tuple{Vararg{Number}}) = ImmutableDiffResult(value, derivs)
function DiffResult(value::Union{Number,AbstractArray}, derivs::Tuple{Vararg{AbstractArray}})
if all(ismutablearray, derivs)
return MutableDiffResult(value, derivs)
else
return ImmutableDiffResult(value, derivs)
end
end |
|
Is it type-inferrable to do |
|
I'm sure up to a certain extent 😄 But I haven't tested it. IIRC sometimes one can help the compiler by defining such checks recursively. And if the checks only depend on types (and instances are not needed), one could use But how many orders of derivatives do people realistically work with? So I think in most cases |
|
FWIW, I am not sure that mixing |
Reverts #32