-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Fix #42670 - error in sparsevec outer product with stored zeros #42671
Conversation
The SparseMatrixCSC constructor checks that the passed in buffers have length matching the expected number of non-zeros, but the _outer constructor allocated buffers of the number of structural non-zeros, not actual non-zeros. Fix this by shrinking the buffers once the outer product is fully computed.
C = sparsevec([0 0 1 1 0 0])' | ||
A[2] = 1 | ||
A[2] = 0 | ||
@test A * C == B * C == spzeros(Int, 4, 6) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test seems to be insufficiently specific as it passes even on v1.6. Perhaps we should include a test like this?
@test A * C == B * C == spzeros(Int, 4, 6) | |
@test A * C == B * C == spzeros(Int, 4, 6) | |
@test length(nonzeros(A * C)) == length(nonzeros(B * C)) == 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That test doesn't test what I care about. I'm fine if the outer product doesn't drop non-structural zeros. If this test passes on 1.6, then this is just a regression, since it doesn't pass (as in throws an error) on master with the error message referenced in the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, your test fails since v1.7. Shall we backport this to v1.7 then?
The SparseMatrixCSC constructor checks that the passed in buffers have length matching the expected number of non-zeros, but the _outer constructor allocated buffers of the number of structural non-zeros, not actual non-zeros. Fix this by shrinking the buffers once the outer product is fully computed. (cherry picked from commit d885fc2)
…ros (JuliaLang#42671) The SparseMatrixCSC constructor checks that the passed in buffers have length matching the expected number of non-zeros, but the _outer constructor allocated buffers of the number of structural non-zeros, not actual non-zeros. Fix this by shrinking the buffers once the outer product is fully computed.
…ros (JuliaLang#42671) The SparseMatrixCSC constructor checks that the passed in buffers have length matching the expected number of non-zeros, but the _outer constructor allocated buffers of the number of structural non-zeros, not actual non-zeros. Fix this by shrinking the buffers once the outer product is fully computed.
The SparseMatrixCSC constructor checks that the passed in buffers
have length matching the expected number of non-zeros, but the
_outer constructor allocated buffers of the number of structural
non-zeros, not actual non-zeros. Fix this by shrinking the buffers
once the outer product is fully computed.
Fixes #42670.