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)
| 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 | """ |