Exemplo n.º 1
0
 def sum(self, axis=None):
     """Sum the matrix over the given axis.  If the axis is None, sum
     over both rows and columns, returning a scalar.
     """
     # The spmatrix base class already does axis=0 and axis=1 efficiently
     # so we only do the case axis=None here
     if axis is None:
         return self.data.sum()
     else:
         return spmatrix.sum(self, axis)
         raise ValueError("axis out of bounds")
Exemplo n.º 2
0
 def sum(self, axis=None):
     """Sum the matrix over the given axis.  If the axis is None, sum
     over both rows and columns, returning a scalar.
     """
     # The spmatrix base class already does axis=0 and axis=1 efficiently
     # so we only do the case axis=None here
     if axis is None:
         return self.data.sum()
     else:
         return spmatrix.sum(self,axis)
         raise ValueError("axis out of bounds")