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