Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name = "SparseArrays"
uuid = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

[deps]
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand All @@ -16,4 +15,4 @@ Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Dates", "Test", "Printf", "InteractiveUtils"]
test = ["Dates", "InteractiveUtils", "Printf", "Test"]
18 changes: 13 additions & 5 deletions test/cholmod.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ module CHOLMODTests

using Test
using SparseArrays.CHOLMOD
using DelimitedFiles
using Random
using Serialization
using LinearAlgebra:
Expand Down Expand Up @@ -216,20 +215,29 @@ end
end

@testset "test Sparse constructor and read_sparse" begin
# avoid dependenting on delimited files
function writedlm(fn, title="", xs...)
open(fn, "w") do file
println(file, title)
for i in xs
println(file, i)
end
end
end
mktempdir() do temp_dir
testfile = joinpath(temp_dir, "tmp.mtx")

writedlm(testfile, ["%%MatrixMarket matrix coordinate real symmetric","3 3 4","1 1 1","2 2 1","3 2 0.5","3 3 1"])
writedlm(testfile, "%%MatrixMarket matrix coordinate real symmetric","3 3 4","1 1 1","2 2 1","3 2 0.5","3 3 1")
@test sparse(CHOLMOD.Sparse(testfile)) == [1 0 0;0 1 0.5;0 0.5 1]
rm(testfile)

writedlm(testfile, ["%%MatrixMarket matrix coordinate complex Hermitian",
"3 3 4","1 1 1.0 0.0","2 2 1.0 0.0","3 2 0.5 0.5","3 3 1.0 0.0"])
writedlm(testfile, "%%MatrixMarket matrix coordinate complex Hermitian",
"3 3 4","1 1 1.0 0.0","2 2 1.0 0.0","3 2 0.5 0.5","3 3 1.0 0.0")
@test sparse(CHOLMOD.Sparse(testfile)) == [1 0 0;0 1 0.5-0.5im;0 0.5+0.5im 1]
rm(testfile)

# this also tests that the error message is correctly retrieved from the library
writedlm(testfile, ["%%MatrixMarket matrix coordinate real symmetric","%3 3 4","1 1 1","2 2 1","3 2 0.5","3 3 1"])
writedlm(testfile, "%%MatrixMarket matrix coordinate real symmetric","%3 3 4","1 1 1","2 2 1","3 2 0.5","3 3 1")
@test_throws CHOLMOD.CHOLMODException("indices out of range") sparse(CHOLMOD.Sparse(testfile))
rm(testfile)
end
Expand Down