Skip to content

Commit

Permalink
tests: explicit random seed
Browse files Browse the repository at this point in the history
  • Loading branch information
alyst committed Jun 18, 2023
1 parent cf5798f commit 83b5cee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ julia = "1.6"
MKL_jll = "2022.2.0, 2023.0.0"

[extras]
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
test = ["Test", "Random"]
14 changes: 13 additions & 1 deletion test/test_BLAS.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using MKLSparse
using Test, SparseArrays, LinearAlgebra
using Test, Random, SparseArrays, LinearAlgebra

# evaluates ex and checks whether it has called any SparseBLAS MKL method
macro blas(ex)
Expand All @@ -24,6 +24,8 @@ matrix_classes = [
]

@testset "MKLSparse.matdescra()" begin
Random.seed!(100500)

sA = sprand(5, 5, 0.01)
sS = sA'sA
sTl = tril(sS)
Expand Down Expand Up @@ -60,6 +62,8 @@ end
local atol::real(T) = 100*eps(real(one(T))) # absolute tolerance for SparseBLAS results

@testset "SparseMatrixCSC{$T} * Vector{$T}" begin
Random.seed!(100500)

for _ in 1:10
spA = sprand(T, 10, 5, 0.5)
a = Array(spA)
Expand All @@ -77,6 +81,8 @@ local atol::real(T) = 100*eps(real(one(T))) # absolute tolerance for SparseBLAS
end

@testset "Vector{$T} * SparseMatrixCSC{$T}" begin
Random.seed!(100500)

for _ in 1:10
spA = sprand(T, 10, 5, 0.5)
a = Array(spA)
Expand All @@ -101,6 +107,8 @@ end
end

@testset "SparseMatrixCSC{$T} * Matrix{$T}" begin
Random.seed!(100500)

for _ in 1:10
spA = sprand(T, 10, 5, 0.5)
a = Array(spA)
Expand Down Expand Up @@ -135,6 +143,8 @@ end

@testset "$Aclass{SparseMatrixCSC{$T}} * $(ifelse(Bdim == 2, "Matrix", "Vector")){$T}" for Bdim in 1:2,
(Aclass, transform_to_class) in matrix_classes
Random.seed!(100500)

for _ in 1:10
n = rand(50:150)
spA = transform_to_class(sprand(T, n, n, 0.5) + convert(real(T), sqrt(n))*I)
Expand All @@ -154,6 +164,8 @@ end

(Aclass == Symmetric) && continue # not implemented in MKLSparse

Random.seed!(100500)

for _ in 1:10
n = rand(50:150)
spA = transform_to_class(sprand(T, n, n, 0.5) + convert(real(T), sqrt(n))*I)
Expand Down

0 comments on commit 83b5cee

Please sign in to comment.