-
-
Notifications
You must be signed in to change notification settings - Fork 124
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
nan
propagation in matrix multiplication
#340
Comments
Yes, this is because we (perhaps incorrectly) assume that |
Is there a use-case for this behaviour? |
I'm doing outer joins, which I've ended up implementing with matrix multiplication since that works fairly consistently across array types. This was an inconsistency I came across. I've already worked around it, just thought it would be good for this behavior to be defined since I wasn't expecting this. FWIW, Julia sparse arrays do the same thing.using LinearAlgebra, SparseArrays
S = sparse(1.0I, 4, 4)
S[3, 3] = NaN
sparse(I, 4, 4) * S
# 4×4 SparseMatrixCSC{Float64,Int64} with 4 stored entries:
# [1, 1] = 1.0
# [2, 2] = 1.0
# [3, 3] = NaN
# [4, 4] = 1.0 |
A short-term solution here would be to have a warning (like you said), (PRs welcome). If we want a long-term solution, we're looking for #365. |
Describe the bug
Matrix multiplication does not propagate
nan
like numpy does.To Reproduce
Expected behavior
I would expect the same values from
numpy
andsparse
. However, I see thatnan
breaks the expected sparsity pattern, which could make efficient implementation difficult. Maybe a warning or error would be appropriate?System
sparse
version (sparse.__version__
) '0.9.1'np.__version__
) '1.18.3'numba.__version__
) '0.49.0'Additional context
The text was updated successfully, but these errors were encountered: