@@ -33,14 +33,18 @@ arrayts = (Array,)
3333 a[1 , 2 ] = 12
3434 @test a isa SparseArrayDOK{elt,2 }
3535 @test size (a) == (2 , 2 )
36+ @test a[1 ] == 0
3637 @test a[1 , 1 ] == 0
3738 @test a[1 , 1 , 1 ] == 0
39+ @test a[3 ] == 12
3840 @test a[1 , 2 ] == 12
3941 @test a[1 , 2 , 1 ] == 12
4042 @test storedlength (a) == 1
43+ @test_throws BoundsError a[5 ]
44+ @test_throws BoundsError a[1 , 3 ]
4145
4246 a = SparseArrayDOK {elt} (undef, 2 , 2 )
43- a[1 , 2 ] = 12
47+ a[3 ] = 12
4448 for b in (similar (a, Float32, (3 , 3 )), similar (a, Float32, Base. OneTo .((3 , 3 ))))
4549 @test b isa SparseArrayDOK{Float32,2 }
4650 @test b == zeros (Float32, 3 , 3 )
@@ -59,13 +63,15 @@ arrayts = (Array,)
5963 # isstored
6064 a = SparseArrayDOK {elt} (undef, 4 , 4 )
6165 a[2 , 3 ] = 23
62- for I in CartesianIndices (a)
66+ for (I, i) in zip ( CartesianIndices (a), LinearIndices (a) )
6367 if I == CartesianIndex (2 , 3 )
6468 @test isstored (a, I)
6569 @test isstored (a, Tuple (I)... )
70+ @test isstored (a, i)
6671 else
6772 @test ! isstored (a, I)
6873 @test ! isstored (a, Tuple (I)... )
74+ @test ! isstored (a, i)
6975 end
7076 end
7177
@@ -83,12 +89,21 @@ arrayts = (Array,)
8389 end
8490 end
8591
92+ # vector
93+ a = SparseArrayDOK {elt} (undef, 2 )
94+ a[2 ] = 12
95+ @test b[1 ] == 0
96+ @test a[2 ] == 12
97+ @test storedlength (a) == 1
98+
8699 a = SparseArrayDOK {elt} (undef, 3 , 3 , 3 )
87100 a[1 , 2 , 3 ] = 123
88101 b = permutedims (a, (2 , 3 , 1 ))
89102 @test b isa SparseArrayDOK{elt,3 }
90103 @test b[2 , 3 , 1 ] == 123
91104 @test storedlength (b) == 1
105+ @test b[1 ] == 0
106+ @test b[LinearIndices (b)[2 , 3 , 1 ]] == 123
92107
93108 a = SparseArrayDOK {elt} (undef, 2 , 2 )
94109 a[1 , 2 ] = 12
0 commit comments