Skip to content

Commit cb46917

Browse files
kshyattdkarrasch
authored andcommitted
Add test for setindex with a matrix of bools (#34388)
1 parent 94249da commit cb46917

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

stdlib/SparseArrays/test/sparse.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1138,6 +1138,18 @@ end
11381138
S[I] .= J
11391139
@test sum(S) == (sumS1 - sumS2 + sum(J))
11401140
end
1141+
1142+
# setindex with a Matrix{Bool}
1143+
Is = fill(false, 10, 10)
1144+
Is[1, 1] = true
1145+
Is[10, 10] = true
1146+
A = sprand(10, 10, 0.2)
1147+
A[Is] = [0.1, 0.5]
1148+
@test A[1, 1] == 0.1
1149+
@test A[10, 10] == 0.5
1150+
A = spzeros(10, 10)
1151+
A[Is] = [0.1, 0.5]
1152+
@test nnz(A) == 2
11411153
end
11421154

11431155
@testset "dropstored!" begin

0 commit comments

Comments
 (0)