172
172
i === nothing && no_dimname_error (T, dim)
173
173
return i
174
174
end
175
- #=
176
- return i
177
- i = 1
178
- out = 0
179
- for s in dimnames(T)
180
- if Symbol(s) === dim
181
- out = i
182
- break
183
- else
184
- i += i
185
- end
186
- end
187
- if out === 0
188
- no_dimname_error(T, dim)
189
- end
190
- return out
191
- end
192
- =#
193
-
194
175
to_dims (:: Type{T} , dims:: Tuple ) where {T} = map (i -> to_dims (T, i), dims)
176
+
195
177
#=
196
178
order_named_inds(names, namedtuple)
197
179
order_named_inds(names, subnames, inds)
@@ -235,49 +217,6 @@ function _order_named_inds_check(inds::Tuple{Vararg{Any,N}}, nkwargs::Int) where
235
217
return nothing
236
218
end
237
219
238
-
239
- #=
240
- name_to_idx(name::StaticSymbol, kwargs::Tuple, inds::Tuple, )
241
- name_to_idx(name::StaticSymbol, kwargs::Tuple, inds::Tuple) = _name_to_index(find_first_eq(), inds)
242
- _name_to_index(::Zero, ::Tuple) = Colon()
243
- _name_to_index(::StaticInt{N}, inds::Tuple) where {N} = getfield(inds, N)
244
-
245
- # return permute(inds, static_find_all_in(nd, x))
246
- _colon_or_inds(inds::Tuple, ::Zero) = :
247
- _colon_or_inds(inds::Tuple, ::StaticInt{I}) where {I} = getfield(inds, I)
248
-
249
- n_i -> _colon_or_inds(inds, find_first_eq(n_i, x))
250
- # FIXME this needs to insert a colon on missing names
251
-
252
- @inline function order_named_inds(val::Val{L}; kwargs...) where {L}
253
- if isempty(kwargs)
254
- return ()
255
- else
256
- return order_named_inds(val, kwargs.data)
257
- end
258
- end
259
- @generated function order_named_inds(val::Val{L}, ni::NamedTuple{K}) where {L,K}
260
- tuple_issubset(K, L) || throw(DimensionMismatch("Expected subset of $L, got $K"))
261
- exs = map(L) do n
262
- if Base.sym_in(n, K)
263
- qn = QuoteNode(n)
264
- :(getfield(ni, $qn))
265
- else
266
- :(Colon())
267
- end
268
- end
269
- return Expr(:tuple, exs...)
270
- end
271
- =#
272
-
273
- @generated function _perm_tuple (:: Type{T} , :: Val{P} ) where {T,P}
274
- out = Expr (:curly , :Tuple )
275
- for p in P
276
- push! (out. args, T. parameters[p])
277
- end
278
- Expr (:block , Expr (:meta , :inline ), out)
279
- end
280
-
281
220
"""
282
221
axes_types(::Type{T}[, d]) -> Type
283
222
@@ -293,14 +232,11 @@ function axes_types(::Type{T}) where {T}
293
232
return axes_types (parent_type (T))
294
233
end
295
234
end
296
- function axes_types (:: Type{T} ) where {T<: Adjoint }
297
- return _perm_tuple (axes_types (parent_type (T)), Val ((2 , 1 )))
298
- end
299
- function axes_types (:: Type{T} ) where {T<: Transpose }
300
- return _perm_tuple (axes_types (parent_type (T)), Val ((2 , 1 )))
235
+ function axes_types (:: Type{T} ) where {T<: MatAdjTrans }
236
+ return eachop_tuple (_get_tuple, axes_types (parent_type (T)), to_parent_dims (T))
301
237
end
302
- function axes_types (:: Type{T} ) where {I1, T<: PermutedDimsArray{<:Any,<:Any,I1} }
303
- return _perm_tuple ( axes_types (parent_type (T)), Val (I1 ))
238
+ function axes_types (:: Type{T} ) where {T<: PermutedDimsArray }
239
+ return eachop_tuple (_get_tuple, axes_types (parent_type (T)), to_parent_dims (T ))
304
240
end
305
241
function axes_types (:: Type{T} ) where {T<: AbstractRange }
306
242
if known_length (T) === nothing
0 commit comments