# [Scipy-tickets] [SciPy] #1526: sparse.lil_matrix assigment bug when indexing with two lists

SciPy Trac scipy-tickets@scipy....
Thu Sep 29 07:14:22 CDT 2011

```#1526: sparse.lil_matrix assigment bug when indexing with two lists
-----------------------------+----------------------------------------------
Reporter:  tony.stillfjord  |       Owner:  wnbell
Type:  defect           |      Status:  new
Priority:  normal           |   Milestone:  0.10.0
Component:  scipy.sparse     |     Version:  0.9.0
Keywords:                   |
-----------------------------+----------------------------------------------

Comment(by tony.stillfjord):

Wow, sorry, I managed to miss *both* the code tags and the preview
button... here is the code formatted in a readable way:

{{{
import numpy
import scipy.sparse

B = numpy.array([[1,2,3],[3,4,5],[6,7,8]])

A = scipy.sparse.lil_matrix(B)

print 'A:', A.todense()
print 'B:', B

print 'Some A-elements:', A[[0,1,2],[1,2,0]].todense()
print 'Some B-elements:', B[[0,1,2],[1,2,0]]

B[[0,1,2],[1,2,0]] = 0

print 'New B:', B

A[[0,1,2],[1,2,0]] = 0

print 'New A:', A.todense()

Output:

A: [[1 2 3]
[3 4 5]
[6 7 8]]
B: [[1 2 3]
[3 4 5]
[6 7 8]]
Some A-elements: [[2 5 6]]
Some B-elements: [2 5 6]
New B: [[1 0 3]
[3 4 0]
[0 7 8]]
New A: [[0 0 0]
[0 0 0]
[0 0 0]]
}}}

--
Ticket URL: <http://projects.scipy.org/scipy/ticket/1526#comment:1>
SciPy <http://www.scipy.org>
SciPy is open-source software for mathematics, science, and engineering.
```