Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue #169 SparseMatrixCSC illegal buffers #170

Merged
merged 1 commit into from
Dec 15, 2021

Conversation

mkitti
Copy link
Member

@mkitti mkitti commented Dec 15, 2021

Fix #169

Truncate row values to the length of the non-zero elements to comply with strict SparseMatrixCSC buffers:
https://github.com/JuliaLang/julia/blob/b3e4341d43da32f4ab6087230d98d00b89c8c004/stdlib/SparseArrays/src/sparsematrix.jl#L86-L90

@johnnychen94
Copy link
Member

Looks good; can you add a test case for this?

@mkitti
Copy link
Member Author

mkitti commented Dec 15, 2021

We already have a test case for this. It's been failing.

ERROR: LoadError: ArgumentError: Illegal buffers for SparseMatrixCSC construction 20 [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1] [1] Float64[]
Stacktrace:
  [1] SparseMatrixCSC
    @ /opt/hostedtoolcache/julia/1.7.0/x64/share/julia/stdlib/v1.7/SparseArrays/src/sparsematrix.jl:29 [inlined]
  [2] SparseMatrixCSC(m::Int64, n::Int64, colptr::Vector{Int64}, rowval::Vector{Int64}, nzval::Vector{Float64})
    @ SparseArrays /opt/hostedtoolcache/julia/1.7.0/x64/share/julia/stdlib/v1.7/SparseArrays/src/sparsematrix.jl:44
  [3] read_sparse(f::IOStream, swap_bytes::Bool, dimensions::Vector{Int32}, flags::Vector{UInt32})
    @ MAT.MAT_v5 ~/work/MAT.jl/MAT.jl/src/MAT_v5.jl:248
  [4] read_matrix(f::IOStream, swap_bytes::Bool)
    @ MAT.MAT_v5 ~/work/MAT.jl/MAT.jl/src/MAT_v5.jl:340
  [5] read(matfile::MAT.MAT_v5.Matlabv5File, varname::String)
    @ MAT.MAT_v5 ~/work/MAT.jl/MAT.jl/src/MAT_v5.jl:413
  [6] check(filename::String, result::Dict{String, SparseMatrixCSC{Tv, Int64} where Tv})
    @ Main ~/work/MAT.jl/MAT.jl/test/read.jl:7
  [7] top-level scope
    @ ~/work/MAT.jl/MAT.jl/test/read.jl:137
  [8] include(fname::String)
    @ Base.MainInclude ./client.jl:451
  [9] top-level scope
    @ ~/work/MAT.jl/MAT.jl/test/runtests.jl:3
 [10] include(fname::String)
    @ Base.MainInclude ./client.jl:451
 [11] top-level scope
    @ none:6

@mkitti
Copy link
Member Author

mkitti commented Dec 15, 2021

@johnnychen94 johnnychen94 merged commit 50b1230 into master Dec 15, 2021
@johnnychen94 johnnychen94 deleted the mkitti/fix_169_SparseMatrixCSC_illegal_buffers branch December 15, 2021 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sparse matrix error Julia 1.7, stricter buffers in SparseMatrixCSC
2 participants