add dtype and out
@@ -73,7 +73,7 @@ class _data_matrix(base.spmatrix):
"""
return cupy.count_nonzero(self.data)
- def mean(self, axis=None):
+ def mean(self, axis=None, dtype=None, out=None):
"""Compute the arithmetic mean along the specified axis.
Args:
@@ -88,18 +88,21 @@ class _data_matrix(base.spmatrix):
:meth:`scipy.sparse.spmatrix.mean`
"""
- nRow = self.shape[0]
- nCol = self.shape[1]
+ validateaxis(axis)
+ nRow, nCol = self.shape
data = self.data.copy()
+
if not axis:
data = cupy.true_divide(data, nRow * nCol)
- return self._with_data(data).sum(axis)
+ return self._with_data(data).sum(axis, dtype, out)
+
if axis == 0 or axis == -2:
data = cupy.true_divide(data, nRow)
- return self._with_data(data).sum(axis)
+ return self._with_data(data).sum(axis, dtype, out)
+
else:
data = cupy.true_divide(data, nCol)
- return self._with_data(data).sum(axis).flatten()
+ return self._with_data(data).sum(axis, dtype, out).flatten()
def power(self, n, dtype=None):
"""Elementwise power function.
