-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Make broadcast over sparse and rowvecs sparse #20959
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -403,16 +403,19 @@ end | |
densearrays = (C, M) | ||
fD, fB = Array(D), Array(B) | ||
for X in densearrays | ||
@test (Q = broadcast(+, D, X); Q isa SparseMatrixCSC && Q == sparse(broadcast(+, fD, X))) | ||
@test broadcast(+, D, X)::SparseMatrixCSC == sparse(broadcast(+, fD, X)) | ||
@test broadcast!(+, Z, D, X) == sparse(broadcast(+, fD, X)) | ||
@test (Q = broadcast(*, s, B, X); Q isa SparseMatrixCSC && Q == sparse(broadcast(*, s, fB, X))) | ||
@test broadcast(*, s, B, X)::SparseMatrixCSC == sparse(broadcast(*, s, fB, X)) | ||
@test broadcast!(*, Z, s, B, X) == sparse(broadcast(*, s, fB, X)) | ||
@test (Q = broadcast(+, V, B, X); Q isa SparseMatrixCSC && Q == sparse(broadcast(+, fV, fB, X))) | ||
@test broadcast(+, V, B, X)::SparseMatrixCSC == sparse(broadcast(+, fV, fB, X)) | ||
@test broadcast!(+, Z, V, B, X) == sparse(broadcast(+, fV, fB, X)) | ||
@test (Q = broadcast(+, V, A, X); Q isa SparseMatrixCSC && Q == sparse(broadcast(+, fV, fA, X))) | ||
@test broadcast(+, V, A, X)::SparseMatrixCSC == sparse(broadcast(+, fV, fA, X)) | ||
@test broadcast!(+, Z, V, A, X) == sparse(broadcast(+, fV, fA, X)) | ||
@test (Q = broadcast(*, s, V, A, X); Q isa SparseMatrixCSC && Q == sparse(broadcast(*, s, fV, fA, X))) | ||
@test broadcast(*, s, V, A, X)::SparseMatrixCSC == sparse(broadcast(*, s, fV, fA, X)) | ||
@test broadcast!(*, Z, s, V, A, X) == sparse(broadcast(*, s, fV, fA, X)) | ||
# Issue #20954 combinations of sparse arrays and RowVectors | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is intentional. It would work now, so this would make sure it doesn't regress in the future if/when the lazy transposition of matrices land. |
||
@test broadcast(+, A, X')::SparseMatrixCSC == sparse(broadcast(+, fA, X')) | ||
@test broadcast(*, V, X')::SparseMatrixCSC == sparse(broadcast(*, fV, X')) | ||
end | ||
end | ||
|
||
|
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.
As I mentioned in #20102, I like these changes: These definitions are safer if we at some point broaden the set of type combinations sparse
broadcast[!]
captures. On the other hand, absent that broadening, being explicit about the types sparsebroadcast[!]
handles and what it does with them is also nice. But then being explicit in_spcontainertype
should be sufficient, so I favor keeping these changes. Thoughts?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.
I'd also prefer having this and if necessary, then being more conservative over
_spcontainertype
.