Skip to content

map over Adjoint assumes that the result supports adjoint #1015

Open
@jishnub

Description

@jishnub

The following is broken as a consequence

julia> a = [[1,2,3]]'
1×1 adjoint(::Vector{Vector{Int64}}) with eltype LinearAlgebra.Adjoint{Int64, Vector{Int64}}:
 [1 2 3]

julia> map(size, a)
ERROR: MethodError: no method matching adjoint(::Tuple{Int64, Int64})

Closest candidates are:
  adjoint(::Missing)
   @ Base missing.jl:101
  adjoint(::LinearAlgebra.Givens)
   @ LinearAlgebra ~/packages/julias/julia-latest/share/julia/stdlib/v1.11/LinearAlgebra/src/givens.jl:60
  adjoint(::LinearAlgebra.UnitLowerTriangular)
   @ LinearAlgebra ~/packages/julias/julia-latest/share/julia/stdlib/v1.11/LinearAlgebra/src/triangular.jl:409
  ...

Stacktrace:
 [1] (::LinearAlgebra.var"#1#2"{typeof(size)})(xs::Vector{Int64})
   @ LinearAlgebra ~/packages/julias/julia-latest/share/julia/stdlib/v1.11/LinearAlgebra/src/adjtrans.jl:403
 [2] iterate(::Base.Generator{Vector{Vector{Int64}}, LinearAlgebra.var"#1#2"{typeof(size)}})
   @ Base ./generator.jl:47 [inlined]
 [3] _collect(c::Vector{Vector{Int64}}, itr::Base.Generator{Vector{Vector{Int64}}, LinearAlgebra.var"#1#2"{typeof(size)}}, ::Base.EltypeUnknown, isz::Base.HasShape{1})
   @ Base ./array.jl:852 [inlined]
 [4] collect_similar(cont::Vector{Vector{Int64}}, itr::Base.Generator{Vector{Vector{Int64}}, LinearAlgebra.var"#1#2"{typeof(size)}})
   @ Base ./array.jl:761
 [5] map(f::Function, A::Vector{Vector{Int64}})
   @ Base ./abstractarray.jl:3273
 [6] map(f::Function, avs::LinearAlgebra.Adjoint{LinearAlgebra.Adjoint{Int64, Vector{Int64}}, Vector{Vector{Int64}}})
   @ LinearAlgebra ~/packages/julias/julia-latest/share/julia/stdlib/v1.11/LinearAlgebra/src/adjtrans.jl:403
 [7] top-level scope
   @ REPL[2]:1

julia> VERSION
v"1.11.0-DEV.78"

The broadcasted operation works as expected:

julia> size.(a)
1×1 Matrix{Tuple{Int64, Int64}}:
 (1, 3)

This error happens on v1.9 and 1.10 as well.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions