Skip to content

Commit 84b0965

Browse files
authored
Merge pull request #151 from JuliaArrays/adjvecaxes
Make axes(::Adjoint{<:Any,<:AbstractVector},1) == One():One()
2 parents 39c9db3 + ac4680f commit 84b0965

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
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.11"
3+
version = "3.1.12"
44

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

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)