File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -248,8 +248,11 @@ function _projection_mismatch(axes_x::Tuple, size_dx::Tuple)
248
248
)
249
249
end
250
250
251
+ # ####
252
+ # #### `Base`, part II: return of the Tangent
253
+ # ####
254
+
251
255
# Ref
252
- # This can't be its own tangent, so it standardises on a Tangent{<:Ref}
253
256
function ProjectTo (x:: Ref )
254
257
sub = ProjectTo (x[]) # should we worry about isdefined(Ref{Vector{Int}}(), :x)?
255
258
if sub isa ProjectTo{<: AbstractZero }
@@ -258,7 +261,6 @@ function ProjectTo(x::Ref)
258
261
return ProjectTo {Ref} (; type= typeof (x), x= sub)
259
262
end
260
263
end
261
- (project:: ProjectTo{Ref} )(dx:: Ref ) = Tangent {project.type} (; x= project. x (dx[]))
262
264
(project:: ProjectTo{Ref} )(dx:: Tangent ) = Tangent {project.type} (; x= project. x (dx. x))
263
265
# Since this works like a zero-array in broadcasting, it should also accept a number:
264
266
(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))
114
114
115
115
@testset " Base: Ref" begin
116
116
pref = ProjectTo (Ref (2.0 ))
117
- @test pref (Ref (3 + im)). x === 3.0
117
+ @test_skip pref (Ref (3 + im)). x === 3.0
118
118
@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 }
120
120
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
122
122
123
123
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}
125
125
@test_throws DimensionMismatch prefvec (Ref {Any} (1 : 5 ))
126
126
127
127
@test ProjectTo (Ref (true )) isa ProjectTo{NoTangent}
You can’t perform that action at this time.
0 commit comments