Skip to content

Commit 5cd6489

Browse files
committed
Revert "Clean up code and version bump"
This reverts commit fcb6341.
1 parent fcb6341 commit 5cd6489

File tree

5 files changed

+72
-16
lines changed

5 files changed

+72
-16
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "ArrayInterface"
22
uuid = "4fba245c-0d91-5ea0-9b3e-6abc04ee57a9"
3-
version = "3.1"
3+
version = "3.0.2"
44

55
[deps]
66
IfElse = "615f187c-cbe4-4ef1-ba3b-2fcf58d6d173"

src/ArrayInterface.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ using LinearAlgebra
66
using SparseArrays
77
using Base.Cartesian
88

9-
using Base: @propagate_inbounds, tail, OneTo, LogicalIndex, Slice, ReinterpretArray
9+
using Base: @pure, @propagate_inbounds, tail, OneTo, LogicalIndex, Slice, ReinterpretArray
1010

1111
Base.@pure __parameterless_type(T) = Base.typename(T).wrapper
1212
parameterless_type(x) = parameterless_type(typeof(x))

src/dimensions.jl

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,26 @@ end
172172
i === nothing && no_dimname_error(T, dim)
173173
return i
174174
end
175-
to_dims(::Type{T}, dims::Tuple) where {T} = map(i -> to_dims(T, i), dims)
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+
=#
176193

194+
to_dims(::Type{T}, dims::Tuple) where {T} = map(i -> to_dims(T, i), dims)
177195
#=
178196
order_named_inds(names, namedtuple)
179197
order_named_inds(names, subnames, inds)
@@ -217,6 +235,49 @@ function _order_named_inds_check(inds::Tuple{Vararg{Any,N}}, nkwargs::Int) where
217235
return nothing
218236
end
219237

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+
220281
"""
221282
axes_types(::Type{T}[, d]) -> Type
222283
@@ -232,11 +293,14 @@ function axes_types(::Type{T}) where {T}
232293
return axes_types(parent_type(T))
233294
end
234295
end
235-
function axes_types(::Type{T}) where {T<:MatAdjTrans}
236-
return eachop_tuple(_get_tuple, axes_types(parent_type(T)), to_parent_dims(T))
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)))
237301
end
238-
function axes_types(::Type{T}) where {T<:PermutedDimsArray}
239-
return eachop_tuple(_get_tuple, axes_types(parent_type(T)), to_parent_dims(T))
302+
function axes_types(::Type{T}) where {I1,T<:PermutedDimsArray{<:Any,<:Any,I1}}
303+
return _perm_tuple(axes_types(parent_type(T)), Val(I1))
240304
end
241305
function axes_types(::Type{T}) where {T<:AbstractRange}
242306
if known_length(T) === nothing

src/indexing.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -662,4 +662,3 @@ end
662662
) where {N}
663663
return _generate_unsafe_setindex!_body(N)
664664
end
665-

src/static.jl

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@ function invariant_permutation(x::T, y::T) where {N,T<:Tuple{Vararg{StaticInt,N}
272272
end
273273

274274
permute(x::Tuple, perm::Val) = permute(x, static(perm))
275+
# TODO delete this? permute(x::Tuple, perm::Tuple) = eachop(getindex, x, perm)
275276
function permute(x::Tuple{Vararg{Any}}, perm::Tuple{Vararg{StaticInt}})
276277
if invariant_permutation(perm, perm) isa False
277278
return eachop(getindex, x, perm)
@@ -296,14 +297,6 @@ end
296297
Expr(:block, Expr(:meta, :inline), t)
297298
end
298299

299-
@generated function eachop_tuple(op, x, ::I) where {I}
300-
t = Expr(:curly, :Tuple)
301-
for p in I.parameters
302-
push!(t.args, :(op(x, StaticInt{$(p.parameters[1])}())))
303-
end
304-
Expr(:block, Expr(:meta, :inline), t)
305-
end
306-
307300
"""
308301
eq(x::StaticInt, y::StaticInt) -> StaticBool
309302

0 commit comments

Comments
 (0)