ForwardDiff.jl icon indicating copy to clipboard operation
ForwardDiff.jl copied to clipboard

`construct_seeds` for types where `typeof(one(T)) !=T` is broken

Open longemen3000 opened this issue 2 years ago • 1 comments

as far as i understand, the type of one(T) is not necessarily T (https://github.com/JuliaPhysics/Measurements.jl/issues/134 for example). but construct_seeds uses this: https://github.com/JuliaDiff/ForwardDiff.jl/blob/50ec9a1ccb0a4390edc88398aa322656d58e7202/src/partials.jl#L9-L12 Maybe using oneunit there is more correct?

longemen3000 avatar Jun 07 '23 22:06 longemen3000

If you want to get something of the same type, you should use oneunit, that's what it's for.

(e.g. for a dimensionful type, one must be dimensionless, i.e. of a different type, as otherwise it will not be a multiplicative identity.)

stevengj avatar Sep 18 '23 14:09 stevengj