MCPcopy
hub / github.com/numpy/numpy / prod

Method prod

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

5301 return result
5302
5303 def prod(self, axis=None, dtype=None, out=None, keepdims=np._NoValue):
5304 """
5305 Return the product of the array elements over the given axis.
5306
5307 Masked elements are set to 1 internally for computation.
5308
5309 Refer to `numpy.prod` for full documentation.
5310
5311 Notes
5312 -----
5313 Arithmetic is modular when using integer types, and no error is raised
5314 on overflow.
5315
5316 See Also
5317 --------
5318 numpy.ndarray.prod : corresponding function for ndarrays
5319 numpy.prod : equivalent function
5320 """
5321 kwargs = {} if keepdims is np._NoValue else {'keepdims': keepdims}
5322
5323 _mask = self._mask
5324 newmask = _check_mask_axis(_mask, axis, **kwargs)
5325 # No explicit output
5326 if out is None:
5327 result = self.filled(1).prod(axis, dtype=dtype, **kwargs)
5328 rndim = getattr(result, 'ndim', 0)
5329 if rndim:
5330 result = result.view(type(self))
5331 result.__setmask__(newmask)
5332 elif newmask:
5333 result = masked
5334 return result
5335 # Explicit output
5336 result = self.filled(1).prod(axis, dtype=dtype, out=out, **kwargs)
5337 if isinstance(out, MaskedArray):
5338 outmask = getmask(out)
5339 if outmask is nomask:
5340 outmask = out._mask = make_mask_none(out.shape)
5341 outmask.flat = newmask
5342 return out
5343 product = prod
5344
5345 def cumprod(self, axis=None, dtype=None, out=None):

Callers 15

fromfileFunction · 0.45
sizeFunction · 0.45
tensordotFunction · 0.45
test_multiply_reduceFunction · 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

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

test_multiply_reduceFunction · 0.36
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_npyiter_apiFunction · 0.36