Skip to content

Can't cache AbstractQ on Julia v1.10 #285

Closed
@jishnub

Description

@jishnub
julia> using LazyArrays, LinearAlgebra

julia> Q = qr(rand(3,4)).Q;

julia> cache(Q)
ERROR: MethodError: no method matching similar(::LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}}, ::Tuple{Int64, Int64})

Closest candidates are:
  similar(::JuliaInterpreter.Compiled, ::Any)
   @ JuliaInterpreter ~/.julia/packages/JuliaInterpreter/EsH1r/src/types.jl:7
  similar(::Type{T}, ::Tuple{Vararg{Int64, N}} where N) where T<:AbstractArray
   @ Base abstractarray.jl:874
  similar(::Type{T}, ::Tuple{Union{Integer, Base.OneTo}, Vararg{Union{Integer, Base.OneTo}}}) where T<:AbstractArray
   @ Base abstractarray.jl:873
  ...

Stacktrace:
 [1] LazyArrays.CachedArray(array::LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}})
   @ LazyArrays ~/Dropbox/JuliaPackages/LazyArrays.jl/src/cache.jl:46
 [2] _cache(::ArrayLayouts.QRCompactWYQLayout{ArrayLayouts.DenseColumnMajor, ArrayLayouts.DenseColumnMajor}, O::LinearAlgebra.QRCompactWYQ{Float64, Matrix{…}, Matrix{…}})
   @ LazyArrays ~/Dropbox/JuliaPackages/LazyArrays.jl/src/cache.jl:55
 [3] cache(A::LinearAlgebra.QRCompactWYQ{Float64, Matrix{Float64}, Matrix{Float64}})
   @ LazyArrays ~/Dropbox/JuliaPackages/LazyArrays.jl/src/cache.jl:54
 [4] top-level scope
   @ REPL[3]:1
Some type information was truncated. Use `show(err)` to see complete types.

This is because AbstractQ isn't an AbstractArray anymore. The fix to this might require relaxing the type-signature of a CachedArray to accept non-array types that implement the array interface.

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