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
ENH: allow addition/substraction of 0 to a sparse matrix #171
Conversation
I'd change the error text to specify "adding a nonzero scalar..." |
Also, this behavior may lead to some confusion: with dense matrices, adding zero returns a copy. Sparse matrices should probably behave the same way to be consistent. |
Jacob Vanderplas wrote:
Done. |
Out of curiosity, what use case do you have in mind for this? I can't think of any case where I'd want to add a scalar to a matrix, raising an error unless the scalar is zero. That would essentially require me to explicitly check to see if the scalar is zero before the operation. But if I know it's zero, why would I do this operation, except as a roundabout path to a matrix copy? |
Jacob Vanderplas wrote:
sum(a_list_of_sparse_matrices) |
Makes sense! |
I'd like to merge this soon unless somebody objects. |
Sorry - I lost track of this in all the buzz around pycon! |
Jacob Vanderplas wrote:
Test added. By the way, there's a test in |
Nice work on the test, I'll merge this now. |
ENH: allow addition/substraction of 0 to a sparse matrix
Jacob Vanderplas wrote:
The test failure was only in the topic branch. Now that you've merged |
No description provided.