Skip to content

Commit 1f5e4fa

Browse files
authored
Float(Dual(x,y)) == Dual(Float(x), Float(y))
1 parent ae94b02 commit 1f5e4fa

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/dual.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ end
315315
end
316316

317317
for F in (:Float16, :Float32, :Float64)
318-
@eval @inline Base.$F(d::Dual) = $F(value(d))
318+
@eval @inline Base.$F(d::Dual{T,V,N}) where {T,V,N} = convert(Dual{T,promote_type(V, $F),N}, d)
319319
end
320320

321321
@inline Random.rand(rng::AbstractRNG, d::Dual) = rand(rng, value(d))

test/DualTest.jl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -519,9 +519,8 @@ end
519519
end
520520

521521
@testset "Float" begin
522-
x = Dual(1.0, 0)
523522
for F in (Float16, Float32, Float64)
524-
@test F(1.0) == F(x)
523+
@test F(Dual(3, 5)) == Dual(F(3), F(5))
525524
end
526525
end
527526

0 commit comments

Comments
 (0)