Skip to content

Commit

Permalink
better code expression in mat_multiector
Browse files Browse the repository at this point in the history
  • Loading branch information
akstrfn committed Aug 3, 2017
1 parent bb8b6c2 commit 315851c
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions scipy/sparse/dok.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ class dok_matrix(spmatrix, IndexMixin, dict):
format = 'dok'

def __init__(self, arg1, shape=None, dtype=None, copy=False):
# TODO: constructor from iterable?
dict.__init__(self)
spmatrix.__init__(self)

Expand Down Expand Up @@ -124,7 +123,6 @@ def _update(self, data):
from other spmatrix classes. Has no checking if `data` is valid."""
return dict.update(self, data)


def getnnz(self, axis=None):
if axis is not None:
raise NotImplementedError("getnnz over an axis is not implemented "
Expand Down Expand Up @@ -246,7 +244,6 @@ def _getitem_ranges(self, i_indices, j_indices, shape):
continue
dict.__setitem__(newdok, (a, b),
dict.__getitem__(self, (ii, jj)))

return newdok

def __setitem__(self, index, x):
Expand Down Expand Up @@ -380,9 +377,9 @@ def _mul_vector(self, other):

def _mul_multivector(self, other):
# matrix * multivector
M, N = self.shape
n_vecs = other.shape[1]
result = np.zeros((M, n_vecs), dtype=upcast(self.dtype, other.dtype))
result_shape = (self.shape[0], other.shape[1])
result_dtype = upcast(self.dtype, other.dtype)
result = np.zeros(result_shape, dtype=result_dtype)
for (i, j), v in iteritems(self):
result[i,:] += v * other[j,:]
return result
Expand Down

0 comments on commit 315851c

Please sign in to comment.