Skip to content

Commit 61113c8

Browse files
author
Keith Clawson
committed
Fix bug from ticket scipy#1604 and add regression test.
1 parent e91e335 commit 61113c8

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

scipy/sparse/lil.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ def _get1(self, i, j):
195195
if pos != len(data) and row[pos] == j:
196196
return data[pos]
197197
else:
198-
return 0
198+
return self.dtype.type(0)
199199

200200
def _slicetoseq(self, j, shape):
201201
if j.start is not None and j.start < 0:

scipy/sparse/tests/test_base.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1609,6 +1609,11 @@ def test_inplace_ops(self):
16091609

16101610
assert_array_equal(result.todense(), expected.todense())
16111611

1612+
# Ticket 1604.
1613+
A = lil_matrix((1,3), dtype=np.dtype('float64'))
1614+
B = array([0.1,0.1,0.1])
1615+
A[0,:] += B
1616+
assert_array_equal(A[0,:].toarray().squeeze(), B)
16121617

16131618
def test_lil_slice_assignment(self):
16141619
B = lil_matrix((4,3))

0 commit comments

Comments
 (0)