Skip to content

[BUG] TensorAlgebra.qr(::SparseArrays.SparseMatrixCSC, ...) broken #21

@mtfishman

Description

@mtfishman

For example:

julia> using TensorAlgebra

julia> using SparseArrays

julia> TensorAlgebra.qr(sprandn(2, 2, 0.5), ("i", "j"), ("i",), ("j",))
ERROR: MethodError: no method matching iterate(::SparseArrays.SPQR.QRSparse{Float64, Int64})
The function `iterate` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  iterate(::SimpleTraits.GenerateTypeVars{:upcase})
   @ SimpleTraits ~/.julia/packages/SimpleTraits/l1ZsK/src/SimpleTraits.jl:445
  iterate(::SimpleTraits.GenerateTypeVars{:lcase})
   @ SimpleTraits ~/.julia/packages/SimpleTraits/l1ZsK/src/SimpleTraits.jl:446
  iterate(::SimpleTraits.GenerateTypeVars{:upcase}, ::Any)
   @ SimpleTraits ~/.julia/packages/SimpleTraits/l1ZsK/src/SimpleTraits.jl:445
  ...

Stacktrace:
 [1] indexed_iterate(I::SparseArrays.SPQR.QRSparse{Float64, Int64}, i::Int64)
   @ Base ./tuple.jl:162
 [2] qr(a::SparseMatrixCSC{Float64, Int64}, biperm::TensorAlgebra.BlockedPermutation{2, (1, 1), Tuple{Int64, Int64}})
   @ TensorAlgebra ~/.julia/packages/TensorAlgebra/p4Ouf/src/factorizations.jl:8
 [3] qr(a::SparseMatrixCSC{Float64, Int64}, labels_a::Tuple{String, String}, labels_codomain::Tuple{String}, labels_domain::Tuple{String})
   @ TensorAlgebra ~/.julia/packages/TensorAlgebra/p4Ouf/src/factorizations.jl:20
 [4] top-level scope
   @ REPL[10]:1

julia> pkgversion(TensorAlgebra)
v"0.1.7"

The reason for the error is that LinearAlgebra.qr(::SparseArrays.SparseMatrixCSC) outputs a factorization object that can't be unpacked as a tuple:

julia> using LinearAlgebra

julia> using SparseArrays

julia> q, r = qr(sprandn(2, 2, 0.5))
ERROR: MethodError: no method matching iterate(::SparseArrays.SPQR.QRSparse{Float64, Int64})
The function `iterate` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  iterate(::SimpleTraits.GenerateTypeVars{:upcase})
   @ SimpleTraits ~/.julia/packages/SimpleTraits/l1ZsK/src/SimpleTraits.jl:445
  iterate(::SimpleTraits.GenerateTypeVars{:lcase})
   @ SimpleTraits ~/.julia/packages/SimpleTraits/l1ZsK/src/SimpleTraits.jl:446
  iterate(::SimpleTraits.GenerateTypeVars{:upcase}, ::Any)
   @ SimpleTraits ~/.julia/packages/SimpleTraits/l1ZsK/src/SimpleTraits.jl:445
  ...

Stacktrace:
 [1] indexed_iterate(I::SparseArrays.SPQR.QRSparse{Float64, Int64}, i::Int64)
   @ Base ./tuple.jl:162
 [2] top-level scope
   @ REPL[16]:1

which is being used inside TensorAlgebra.qr.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions