|
1 | 1 | using Adapt: adapt |
2 | 2 | using ArrayLayouts: zero! |
| 3 | +using Dictionaries: Dictionary |
3 | 4 | using JLArrays: JLArray, @allowscalar |
4 | 5 | using SparseArraysBase: |
5 | 6 | SparseArraysBase, |
@@ -222,22 +223,29 @@ arrayts = (Array,) |
222 | 223 | @test a == [11 12; 12 22] |
223 | 224 | @test storedlength(a) == 4 |
224 | 225 |
|
225 | | - d = Dict([CartesianIndex(1, 2) => elt(12), CartesianIndex(2, 1) => elt(21)]) |
226 | | - for a in ( |
227 | | - sparse(d, 2, 2), |
228 | | - sparse(d, 2, 2; getunstored=Returns(zero(elt))), |
229 | | - sparse(d, (2, 2)), |
230 | | - sparse(d, (2, 2); getunstored=Returns(zero(elt))), |
| 226 | + for d in ( |
| 227 | + Dict([CartesianIndex(1, 2) => elt(12), CartesianIndex(2, 1) => elt(21)]), |
| 228 | + Dictionary([CartesianIndex(1, 2), CartesianIndex(2, 1)], [elt(12), elt(21)]), |
231 | 229 | ) |
232 | | - @test !iszero(a) |
233 | | - @test iszero(a[1, 1]) |
234 | | - @test a[2, 1] == elt(21) |
235 | | - @test a[1, 2] == elt(12) |
236 | | - @test iszero(a[2, 2]) |
237 | | - @test size(a) == (2, 2) |
238 | | - @test storedlength(a) == 2 |
239 | | - @test eltype(a) === elt |
240 | | - @test a isa SparseMatrixDOK{elt} |
| 230 | + for a in ( |
| 231 | + sparse(d, 2, 2), |
| 232 | + sparse(d, 2, 2; getunstored=Returns(zero(elt))), |
| 233 | + sparse(d, (2, 2)), |
| 234 | + sparse(d, (2, 2); getunstored=Returns(zero(elt))), |
| 235 | + # Determine the size automatically. |
| 236 | + sparse(d), |
| 237 | + sparse(d; getunstored=Returns(zero(elt))), |
| 238 | + ) |
| 239 | + @test !iszero(a) |
| 240 | + @test iszero(a[1, 1]) |
| 241 | + @test a[2, 1] == elt(21) |
| 242 | + @test a[1, 2] == elt(12) |
| 243 | + @test iszero(a[2, 2]) |
| 244 | + @test size(a) == (2, 2) |
| 245 | + @test storedlength(a) == 2 |
| 246 | + @test eltype(a) === elt |
| 247 | + @test a isa SparseMatrixDOK{elt} |
| 248 | + end |
241 | 249 | end |
242 | 250 |
|
243 | 251 | for (a, elt′) in ( |
|
0 commit comments