Permalink
Browse files

Applied bug fix for ticket #204 from trunk

  • Loading branch information...
1 parent 6bc7e72 commit 1acaecf673d4b642ac254ad507dd12c5c22498bf edschofield committed May 24, 2006
Showing with 3 additions and 16 deletions.
  1. +3 −16 Lib/sparse/sparse.py
View
19 Lib/sparse/sparse.py
@@ -2603,22 +2603,9 @@ def __setitem__(self, index, x):
else:
x = x.squeeze()
- # Below here x is a 1d array of correct size
-
- # Are we adding an entire row to a currently empty
- # row? Special case -- this can be done fast
- if len(row) == 0 and len(seq) == self.shape[1]:
- # Remove zeros. This could be done generically for
- # dense arrays and all sparse matrix formats by
- # implementing a nonzero() method for sparse matrices
- nonzeros = [ind for ind, xi in enumerate(x) if xi != 0]
- x = [x[ind] for ind in nonzeros]
- row[:] = nonzeros
- self.data[i] = x
- else:
- # add elements the slow way
- for k, col in enumerate(seq):
- self[i, col] = x[k]
+ # Add elements one by one
+ for k, col in enumerate(seq):
+ self[i, col] = x[k]
return
return

0 comments on commit 1acaecf

Please sign in to comment.