Permalink
Browse files

BUG: Unable to delete row from lil matrix after scalar multiplication (

…closes #1427).
  • Loading branch information...
1 parent 84c4247 commit 7cdfb3439b4afcec3a99bc2419eee9a1bd115633 @stefanv stefanv committed Nov 2, 2011
Showing with 9 additions and 4 deletions.
  1. +4 −4 scipy/sparse/lil.py
  2. +5 −0 scipy/sparse/tests/test_base.py
View
@@ -359,16 +359,16 @@ def _mul_scalar(self, other):
else:
new = self.copy()
# Multiply this scalar by every element.
- new.data = np.array([[val*other for val in rowvals] for
- rowvals in new.data], dtype=object)
+ new.data[:] = [[val*other for val in rowvals] for
+ rowvals in new.data]
return new
def __truediv__(self, other): # self / other
if isscalarlike(other):
new = self.copy()
# Divide every element by this scalar
- new.data = np.array([[val/other for val in rowvals] for
- rowvals in new.data], dtype=object)
+ new.data = [[val/other for val in rowvals] for
+ rowvals in new.data]
return new
else:
return self.tocsr() / other
@@ -1500,6 +1500,11 @@ def test_point_wise_multiply(self):
[0,0,9],
[0,16,0]])
+ def test_lil_multiply_removal(self):
+ """Ticket #1427."""
+ a = lil_matrix(np.ones((3,3)))
+ a *= 2.
+ a[0, :] = 0
class TestCOO(_TestCommon, TestCase):

0 comments on commit 7cdfb34

Please sign in to comment.