Skip to content

Commit b41a7e2

Browse files
authored
Merge pull request #24720 from Sacha0/reparrtsparse
replace Array{...}(shape...)-like calls in test/sparse
2 parents 15a5aeb + 539bb0d commit b41a7e2

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

test/sparse/sparse.jl

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -266,12 +266,12 @@ end
266266
b = sprandn(5, 5, 0.2)
267267
@test (maximum(abs.(a\b - Array(a)\Array(b))) < 1000*eps())
268268
# test error throwing for bwdTrisolve
269-
@test_throws DimensionMismatch a\Matrix{Float64}(6, 6)
269+
@test_throws DimensionMismatch a\Matrix{Float64}(I, 6, 6)
270270
a = LowerTriangular(I + tril(0.1*sprandn(5, 5, 0.2)))
271271
b = sprandn(5, 5, 0.2)
272272
@test (maximum(abs.(a\b - Array(a)\Array(b))) < 1000*eps())
273273
# test error throwing for fwdTrisolve
274-
@test_throws DimensionMismatch a\Matrix{Float64}(6, 6)
274+
@test_throws DimensionMismatch a\Matrix{Float64}(I, 6, 6)
275275

276276

277277

@@ -426,7 +426,7 @@ end
426426
@test_throws ArgumentError permute!(X, A, p, q, (D = copy(C); resize!(D.nzval, nnz(A) - 1); D))
427427
end
428428
@testset "common error checking of permute[!] methods / source-workcolptr compat" begin
429-
@test_throws DimensionMismatch permute!(A, p, q, C, Vector{eltype(A.rowval)}(length(A.colptr) - 1))
429+
@test_throws DimensionMismatch permute!(A, p, q, C, Vector{eltype(A.rowval)}(uninitialized, length(A.colptr) - 1))
430430
end
431431
@testset "common error checking of permute[!] methods / permutation validity" begin
432432
@test_throws ArgumentError permute!(A, (r = copy(p); r[2] = r[1]; r), q)
@@ -508,16 +508,16 @@ end
508508
@test var(sparse(Int[])) === NaN
509509

510510
for f in (sum, prod, var)
511-
@test isequal(f(spzeros(0, 1), 1), f(Array{Int}(0, 1), 1))
512-
@test isequal(f(spzeros(0, 1), 2), f(Array{Int}(0, 1), 2))
513-
@test isequal(f(spzeros(0, 1), (1, 2)), f(Array{Int}(0, 1), (1, 2)))
514-
@test isequal(f(spzeros(0, 1), 3), f(Array{Int}(0, 1), 3))
511+
@test isequal(f(spzeros(0, 1), 1), f(Matrix{Int}(I, 0, 1), 1))
512+
@test isequal(f(spzeros(0, 1), 2), f(Matrix{Int}(I, 0, 1), 2))
513+
@test isequal(f(spzeros(0, 1), (1, 2)), f(Matrix{Int}(I, 0, 1), (1, 2)))
514+
@test isequal(f(spzeros(0, 1), 3), f(Matrix{Int}(I, 0, 1), 3))
515515
end
516516
for f in (minimum, maximum, findmin, findmax)
517517
@test_throws ArgumentError f(spzeros(0, 1), 1)
518-
@test isequal(f(spzeros(0, 1), 2), f(Array{Int}(0,1), 2))
518+
@test isequal(f(spzeros(0, 1), 2), f(Matrix{Int}(I, 0, 1), 2))
519519
@test_throws ArgumentError f(spzeros(0, 1), (1, 2))
520-
@test isequal(f(spzeros(0, 1), 3), f(Array{Int}(0,1), 3))
520+
@test isequal(f(spzeros(0, 1), 3), f(Matrix{Int}(I, 0, 1), 3))
521521
end
522522
end
523523
end
@@ -1035,7 +1035,7 @@ end
10351035
@test indmax(S) == indmax(A) == CartesianIndex(1,1)
10361036
@test indmin(S) == indmin(A) == CartesianIndex(1,1)
10371037

1038-
A = Array{Int}(0,0)
1038+
A = Matrix{Int}(I, 0, 0)
10391039
S = sparse(A)
10401040
iA = try indmax(A) end
10411041
iS = try indmax(S) end

test/sparse/sparsevector.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ end
426426

427427
@testset "Concatenation" begin
428428
let m = 80, n = 100
429-
A = Array{SparseVector{Float64,Int}}(n)
429+
A = Vector{SparseVector{Float64,Int}}(uninitialized, n)
430430
tnnz = 0
431431
for i = 1:length(A)
432432
A[i] = sprand(m, 0.3)

test/sparse/spqr.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ nn = 100
4141
@test R0[1:n, :] F[:R]
4242
@test norm(R0[n + 1:end, :], 1) < 1e-12
4343

44-
offsizeA = Matrix{Float64}(m+1, m+1)
44+
offsizeA = Matrix{Float64}(I, m+1, m+1)
4545
@test_throws DimensionMismatch A_mul_B!(Q, offsizeA)
4646
@test_throws DimensionMismatch Ac_mul_B!(Q, offsizeA)
4747
@test_throws DimensionMismatch A_mul_B!(offsizeA, Q)

0 commit comments

Comments
 (0)