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

Method prod

numpy/ma/core.py:5233–5272  ·  view source on GitHub ↗

Return the product of the array elements over the given axis. Masked elements are set to 1 internally for computation. Refer to `numpy.prod` for full documentation. Notes ----- Arithmetic is modular when using integer types, and no error is raised

(self, axis=None, dtype=None, out=None, keepdims=np._NoValue)

Source from the content-addressed store, hash-verified

5231 return result
5232
5233 def prod(self, axis=None, dtype=None, out=None, keepdims=np._NoValue):
5234 """
5235 Return the product of the array elements over the given axis.
5236
5237 Masked elements are set to 1 internally for computation.
5238
5239 Refer to `numpy.prod` for full documentation.
5240
5241 Notes
5242 -----
5243 Arithmetic is modular when using integer types, and no error is raised
5244 on overflow.
5245
5246 See Also
5247 --------
5248 numpy.ndarray.prod : corresponding function for ndarrays
5249 numpy.prod : equivalent function
5250 """
5251 kwargs = {} if keepdims is np._NoValue else {'keepdims': keepdims}
5252
5253 _mask = self._mask
5254 newmask = _check_mask_axis(_mask, axis, **kwargs)
5255 # No explicit output
5256 if out is None:
5257 result = self.filled(1).prod(axis, dtype=dtype, **kwargs)
5258 rndim = getattr(result, 'ndim', 0)
5259 if rndim:
5260 result = result.view(type(self))
5261 result.__setmask__(newmask)
5262 elif newmask:
5263 result = masked
5264 return result
5265 # Explicit output
5266 result = self.filled(1).prod(axis, dtype=dtype, out=out, **kwargs)
5267 if isinstance(out, MaskedArray):
5268 outmask = getmask(out)
5269 if outmask is nomask:
5270 outmask = out._mask = make_mask_none(out.shape)
5271 outmask.flat = newmask
5272 return out
5273 product = prod
5274
5275 def cumprod(self, axis=None, dtype=None, out=None):

Callers 15

fromfileFunction · 0.45
normalize_descrFunction · 0.45
_check_assignmentFunction · 0.45
test_attributesMethod · 0.45
test_iter_best_orderFunction · 0.45
test_iter_c_orderFunction · 0.45
test_iter_f_orderFunction · 0.45
test_iter_c_or_f_orderFunction · 0.45
test_scalar_reductionMethod · 0.45

Calls 6

filledMethod · 0.95
_check_mask_axisFunction · 0.85
getmaskFunction · 0.85
make_mask_noneFunction · 0.85
__setmask__Method · 0.80
viewMethod · 0.45

Tested by 15

normalize_descrFunction · 0.36
_check_assignmentFunction · 0.36
test_attributesMethod · 0.36
test_iter_best_orderFunction · 0.36
test_iter_c_orderFunction · 0.36
test_iter_f_orderFunction · 0.36
test_iter_c_or_f_orderFunction · 0.36
test_scalar_reductionMethod · 0.36
test_einsum_broadcastMethod · 0.36