MCPcopy
hub / github.com/numpy/numpy / cumsum

Method cumsum

numpy/ma/core.py:5261–5301  ·  view source on GitHub ↗

Return the cumulative sum of the array elements over the given axis. Masked values are set to 0 internally during the computation. However, their position is saved, and the result will be masked at the same locations. Refer to `numpy.cumsum` for full docume

(self, axis=None, dtype=None, out=None)

Source from the content-addressed store, hash-verified

5259 return out
5260
5261 def cumsum(self, axis=None, dtype=None, out=None):
5262 """
5263 Return the cumulative sum of the array elements over the given axis.
5264
5265 Masked values are set to 0 internally during the computation.
5266 However, their position is saved, and the result will be masked at
5267 the same locations.
5268
5269 Refer to `numpy.cumsum` for full documentation.
5270
5271 Notes
5272 -----
5273 The mask is lost if `out` is not a valid :class:`ma.MaskedArray` !
5274
5275 Arithmetic is modular when using integer types, and no error is
5276 raised on overflow.
5277
5278 See Also
5279 --------
5280 numpy.ndarray.cumsum : corresponding function for ndarrays
5281 numpy.cumsum : equivalent function
5282
5283 Examples
5284 --------
5285 >>> import numpy as np
5286 >>> marr = np.ma.array(np.arange(10), mask=[0,0,0,1,1,1,0,0,0,0])
5287 >>> marr.cumsum()
5288 masked_array(data=[0, 1, 3, --, --, --, 9, 16, 24, 33],
5289 mask=[False, False, False, True, True, True, False, False,
5290 False, False],
5291 fill_value=999999)
5292
5293 """
5294 result = self.filled(0).cumsum(axis=axis, dtype=dtype, out=out)
5295 if out is not None:
5296 if isinstance(out, MaskedArray):
5297 out.__setmask__(self.mask)
5298 return out
5299 result = result.view(type(self))
5300 result.__setmask__(self._mask)
5301 return result
5302
5303 def prod(self, axis=None, dtype=None, out=None, keepdims=np._NoValue):
5304 """

Callers 15

test_attributesMethod · 0.80
test_axis_argumentMethod · 0.80
test_cumsumMethod · 0.80
histogramFunction · 0.80
unwrapFunction · 0.80
_quantileFunction · 0.80
_unique1dFunction · 0.80
stack_arraysFunction · 0.80
array_splitFunction · 0.80
nancumsumFunction · 0.80
__init__Method · 0.80
test_prependMethod · 0.80

Calls 3

filledMethod · 0.95
__setmask__Method · 0.80
viewMethod · 0.45

Tested by 10

test_attributesMethod · 0.64
test_axis_argumentMethod · 0.64
test_cumsumMethod · 0.64
test_prependMethod · 0.64
test_argsMethod · 0.64
test_badargsMethod · 0.64
test_result_valuesMethod · 0.64
test_cumsumMethod · 0.64
test_arraymethodMethod · 0.64
test_cumsumprodMethod · 0.64