MCPcopy Create free account
hub / github.com/numpy/numpy / cumsum

Method cumsum

numpy/ma/core.py:5192–5231  ·  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

5190 return out
5191
5192 def cumsum(self, axis=None, dtype=None, out=None):
5193 """
5194 Return the cumulative sum of the array elements over the given axis.
5195
5196 Masked values are set to 0 internally during the computation.
5197 However, their position is saved, and the result will be masked at
5198 the same locations.
5199
5200 Refer to `numpy.cumsum` for full documentation.
5201
5202 Notes
5203 -----
5204 The mask is lost if `out` is not a valid :class:`ma.MaskedArray` !
5205
5206 Arithmetic is modular when using integer types, and no error is
5207 raised on overflow.
5208
5209 See Also
5210 --------
5211 numpy.ndarray.cumsum : corresponding function for ndarrays
5212 numpy.cumsum : equivalent function
5213
5214 Examples
5215 --------
5216 >>> marr = np.ma.array(np.arange(10), mask=[0,0,0,1,1,1,0,0,0,0])
5217 >>> marr.cumsum()
5218 masked_array(data=[0, 1, 3, --, --, --, 9, 16, 24, 33],
5219 mask=[False, False, False, True, True, True, False, False,
5220 False, False],
5221 fill_value=999999)
5222
5223 """
5224 result = self.filled(0).cumsum(axis=axis, dtype=dtype, out=out)
5225 if out is not None:
5226 if isinstance(out, MaskedArray):
5227 out.__setmask__(self.mask)
5228 return out
5229 result = result.view(type(self))
5230 result.__setmask__(self._mask)
5231 return result
5232
5233 def prod(self, axis=None, dtype=None, out=None, keepdims=np._NoValue):
5234 """

Callers 15

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

Calls 3

filledMethod · 0.95
__setmask__Method · 0.80
viewMethod · 0.45

Tested by 11

test_attributesMethod · 0.64
test_axis_argumentMethod · 0.64
test_cumsumMethod · 0.64
test_basicMethod · 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