Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error msg if closing fill mode when fill mode off #17

Merged
merged 1 commit into from
Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/matrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ function addrow!(
end

function closefillmode!(matrix::DynamicSparseMatrix{K,L,T}) where {K,L,T}
matrix.fillmode || error("Cannot close fill mode because matrix is not in fill mode.")
I, J, V = get_rowids_colids_vals(matrix.buffer)
matrix.fillmode = false
matrix.buffer = nothing
Expand Down
4 changes: 4 additions & 0 deletions test/functional/sparsematrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -483,5 +483,9 @@ function dynsparsematrix_fill_mode()
@test length(matrix4) == 0
@test matrix4[1,1] == 0

## Fifth test : Close fill mode of empty matrix not in fill mode
matrix5 = dynamicsparse(Int, Int, Int; fill_mode = false)
@test_throws ErrorException closefillmode!(matrix5)

return
end