Skip to content

Commit db80549

Browse files
authored
fix addrow!+ test (#27)
* unrestrict type of matrix elements * fix addrow!' * more test * bump version
1 parent 12f1d92 commit db80549

3 files changed

Lines changed: 12 additions & 2 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "DynamicSparseArrays"
22
uuid = "8086fd22-9a0c-46a5-a6c8-6e24676501fe"
33
authors = ["Guillaume Marques <guillaume.marques@protonmail.com>"]
4-
version = "0.5.0"
4+
version = "0.5.1"
55

66
[compat]
77
julia = "1"

src/matrix.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ function addrow!(
7777
addrow!(matrix.buffer, row, colids, vals)
7878
else
7979
for j in 1:length(colids)
80-
setindex!(matrix, row, colids[j], vals[j])
80+
setindex!(matrix, vals[j], row, colids[j])
8181
end
8282
end
8383
return true

test/functional/sparsematrix.jl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,16 @@ function dynsparsematrix_fill_mode()
449449
@test matrix.rowmajor[j, i] == values[i, j]
450450
end
451451

452+
# Try addrow! when fill mode off
453+
row_id = 7
454+
row_cols = [1, 3, 4, 5]
455+
row_vals = [2, 3, 6, 7]
456+
addrow!(matrix, row_id, row_cols, row_vals)
457+
458+
for (k,j) in enumerate(row_cols)
459+
@test matrix[row_id,j] == row_vals[k]
460+
end
461+
452462
## Second test
453463
row = rand(rng, 1:1000, 10_000)
454464
col = rand(rng, 1:1000, 10_000)

0 commit comments

Comments
 (0)