@@ -73,10 +73,6 @@ _maybe_projector(x) = x
73
73
_maybe_call (f:: ProjectTo , x) = f (x)
74
74
_maybe_call (f, x) = f
75
75
76
- # Used for elements of e.g. Array{Any}, trivial projector
77
- _always_projector (x:: Union{AbstractArray, Number, Ref} ) = ProjectTo (x)
78
- _always_projector (x) = ProjectTo ()
79
-
80
76
"""
81
77
ProjectTo(x)
82
78
@@ -164,11 +160,11 @@ end
164
160
165
161
# In other cases, store a projector per element:
166
162
function ProjectTo (xs:: AbstractArray )
167
- elements = map (_always_projector , xs)
163
+ elements = map (ProjectTo , xs)
168
164
if elements isa AbstractArray{<: ProjectTo{<:AbstractZero} }
169
165
return ProjectTo {NoTangent} () # short-circuit if all elements project to zero
170
- elseif elements isa AbstractArray{<: ProjectTo{Any} }
171
- return ProjectTo {AbstractArray} (; element= ProjectTo (), axes= axes (xs)) # ... or all identity projection
166
+ # elseif elements isa AbstractArray{<:ProjectTo{Any}}
167
+ # return ProjectTo{AbstractArray}(; element=ProjectTo(), axes=axes(xs)) # ... or all identity projection
172
168
else
173
169
# Arrays of arrays come here, and will apply projectors individually:
174
170
return ProjectTo {AbstractArray} (; elements= elements, axes= axes (xs))
@@ -208,7 +204,7 @@ function (project::ProjectTo{AbstractArray})(dx::Number) # ... so we restore fro
208
204
end
209
205
210
206
# Ref -- works like a zero-array, also allows restoration from a number:
211
- ProjectTo (x:: Ref ) = ProjectTo {Ref} (; x = _always_projector (x[]))
207
+ ProjectTo (x:: Ref ) = ProjectTo {Ref} (; x = ProjectTo (x[]))
212
208
(project:: ProjectTo{Ref} )(dx:: Ref ) = Ref (project. x (dx[]))
213
209
(project:: ProjectTo{Ref} )(dx:: Number ) = Ref (project. x (dx))
214
210
0 commit comments