Skip to content

Commit 699e61f

Browse files
authored
fix projecting Tangent{Complex} to Number (#535)
1 parent 95612d0 commit 699e61f

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ChainRulesCore"
22
uuid = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
3-
version = "1.11.5"
3+
version = "1.11.6"
44

55
[deps]
66
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"

src/projection.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ end
188188

189189
# Tangents: we prefer to reconstruct numbers, but only safe to try when their constructor
190190
# understands, including a mix of Zeros & reals. Other cases, we just let through:
191-
(project::ProjectTo{<:Complex})(dx::Tangent{<:Complex}) = project(Complex(dx.re, dx.im))
191+
(project::ProjectTo{<:Number})(dx::Tangent{<:Complex}) = project(Complex(dx.re, dx.im))
192192
(::ProjectTo{<:Number})(dx::Tangent{<:Number}) = dx
193193

194194
# Arrays

test/projection.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ struct NoSuperType end
3939
# Tangents
4040
ProjectTo(1.0f0 + 2im)(Tangent{ComplexF64}(; re=1, im=NoTangent())) ===
4141
1.0f0 + 0.0f0im
42+
43+
@test 1.0 === ProjectTo(1.0)(Tangent{ComplexF64}(; re=1, im=NoTangent()))
4244
end
4345

4446
@testset "Dual" begin # some weird Real subtype that we should basically leave alone

0 commit comments

Comments
 (0)