Skip to content

Commit 02afb98

Browse files
committed
Make axes(::Adjoint{<:Any,<:AbstractVector},1) == One():One()
1 parent 39c9db3 commit 02afb98

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/axes.jl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,9 @@ Return a tuple of ranges where each range maps to each element along a dimension
163163
end
164164
end
165165
axes(A::PermutedDimsArray) = permute(axes(parent(A)), to_parent_dims(A))
166-
function axes(A::Union{Transpose,Adjoint})
167-
p = parent(A)
168-
return (axes(p, StaticInt(2)), axes(p, One()))
169-
end
166+
axes(A::Union{Transpose,Adjoint}) = _axes(A, parent(A))
167+
_axes(A::Union{Transpose,Adjoint}, p::AbstractVector) = (One():One(), axes(p, One()))
168+
_axes(A::Union{Transpose,Adjoint}, p::AbstractMatrix) = (axes(p, StaticInt(2)), axes(p, One()))
170169
axes(A::SubArray) = Base.axes(A) # TODO implement ArrayInterface version
171170
axes(A::ReinterpretArray) = Base.axes(A) # TODO implement ArrayInterface version
172171
axes(A::Base.ReshapedArray) = Base.axes(A) # TODO implement ArrayInterface version

test/runtests.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,8 @@ end
774774
@test @inferred(lzaxis[2]) === axis[2]
775775
@test @inferred(lzaxis[1:2:5]) === axis[1:2:5]
776776
@test @inferred(lzaxis[1:2]) === axis[1:2]
777+
@test @inferred(ArrayInterface.axes(Array{Float64}(undef, 4)')) === (StaticInt(1):StaticInt(1),Base.OneTo(4))
778+
@test @inferred(ArrayInterface.axes(Array{Float64}(undef, 4, 3)')) === (Base.OneTo(3),Base.OneTo(4))
777779
end
778780

779781
include("ndindex.jl")

0 commit comments

Comments
 (0)