File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -248,8 +248,11 @@ function _projection_mismatch(axes_x::Tuple, size_dx::Tuple)
248248 )
249249end
250250
251+ # ####
252+ # #### `Base`, part II: return of the Tangent
253+ # ####
254+
251255# Ref
252- # This can't be its own tangent, so it standardises on a Tangent{<:Ref}
253256function ProjectTo (x:: Ref )
254257 sub = ProjectTo (x[]) # should we worry about isdefined(Ref{Vector{Int}}(), :x)?
255258 if sub isa ProjectTo{<: AbstractZero }
@@ -258,7 +261,6 @@ function ProjectTo(x::Ref)
258261 return ProjectTo {Ref} (; type= typeof (x), x= sub)
259262 end
260263end
261- (project:: ProjectTo{Ref} )(dx:: Ref ) = Tangent {project.type} (; x= project. x (dx[]))
262264(project:: ProjectTo{Ref} )(dx:: Tangent ) = Tangent {project.type} (; x= project. x (dx. x))
263265# Since this works like a zero-array in broadcasting, it should also accept a number:
264266(project:: ProjectTo{Ref} )(dx:: Number ) = Tangent {project.type} (; x= project. x (dx))
Original file line number Diff line number Diff line change @@ -114,14 +114,14 @@ Base.zero(x::Dual) = Dual(zero(x.value), zero(x.partial))
114114
115115 @testset " Base: Ref" begin
116116 pref = ProjectTo (Ref (2.0 ))
117- @test pref (Ref (3 + im)). x === 3.0
117+ @test_skip pref (Ref (3 + im)). x === 3.0
118118 @test pref (4 ). x === 4.0 # also re-wraps scalars
119- @test pref (Ref {Any} (5.0 )) isa Tangent{<: Base.RefValue }
119+ @test_skip pref (Ref {Any} (5.0 )) isa Tangent{<: Base.RefValue }
120120 pref2 = ProjectTo (Ref {Any} (6 + 7im ))
121- @test pref2 (Ref (8 )). x === 8.0 + 0.0im
121+ @test_skip pref2 (Ref (8 )). x === 8.0 + 0.0im
122122
123123 prefvec = ProjectTo (Ref ([1 , 2 , 3 + 4im ])) # recurses into contents
124- @test prefvec (Ref (1 : 3 )). x isa Vector{ComplexF64}
124+ @test_skip prefvec (Ref (1 : 3 )). x isa Vector{ComplexF64}
125125 @test_throws DimensionMismatch prefvec (Ref {Any} (1 : 5 ))
126126
127127 @test ProjectTo (Ref (true )) isa ProjectTo{NoTangent}
You can’t perform that action at this time.
0 commit comments