Return the sum of array elements over a given axis treating Not a Numbers (NaNs) as zero. In NumPy versions <= 1.9.0 Nan is returned for slices that are all-NaN or empty. In later versions zero is returned. Parameters ---------- a : array_like Array containing
(a, axis=None, dtype=None, out=None, keepdims=np._NoValue,
initial=np._NoValue, where=np._NoValue)
| 633 | |
| 634 | @array_function_dispatch(_nansum_dispatcher) |
| 635 | def nansum(a, axis=None, dtype=None, out=None, keepdims=np._NoValue, |
| 636 | initial=np._NoValue, where=np._NoValue): |
| 637 | """ |
| 638 | Return the sum of array elements over a given axis treating Not a |
| 639 | Numbers (NaNs) as zero. |
| 640 | |
| 641 | In NumPy versions <= 1.9.0 Nan is returned for slices that are all-NaN or |
| 642 | empty. In later versions zero is returned. |
| 643 | |
| 644 | Parameters |
| 645 | ---------- |
| 646 | a : array_like |
| 647 | Array containing numbers whose sum is desired. If `a` is not an |
| 648 | array, a conversion is attempted. |
| 649 | axis : {int, tuple of int, None}, optional |
| 650 | Axis or axes along which the sum is computed. The default is to compute the |
| 651 | sum of the flattened array. |
| 652 | dtype : data-type, optional |
| 653 | The type of the returned array and of the accumulator in which the |
| 654 | elements are summed. By default, the dtype of `a` is used. An |
| 655 | exception is when `a` has an integer type with less precision than |
| 656 | the platform (u)intp. In that case, the default will be either |
| 657 | (u)int32 or (u)int64 depending on whether the platform is 32 or 64 |
| 658 | bits. For inexact inputs, dtype must be inexact. |
| 659 | out : ndarray, optional |
| 660 | Alternate output array in which to place the result. The default |
| 661 | is ``None``. If provided, it must have the same shape as the |
| 662 | expected output, but the type will be cast if necessary. See |
| 663 | :ref:`ufuncs-output-type` for more details. The casting of NaN to integer |
| 664 | can yield unexpected results. |
| 665 | keepdims : bool, optional |
| 666 | If this is set to True, the axes which are reduced are left |
| 667 | in the result as dimensions with size one. With this option, |
| 668 | the result will broadcast correctly against the original `a`. |
| 669 | |
| 670 | If the value is anything but the default, then |
| 671 | `keepdims` will be passed through to the `mean` or `sum` methods |
| 672 | of sub-classes of `ndarray`. If the sub-classes methods |
| 673 | does not implement `keepdims` any exceptions will be raised. |
| 674 | initial : scalar, optional |
| 675 | Starting value for the sum. See `~numpy.ufunc.reduce` for details. |
| 676 | |
| 677 | .. versionadded:: 1.22.0 |
| 678 | where : array_like of bool, optional |
| 679 | Elements to include in the sum. See `~numpy.ufunc.reduce` for details. |
| 680 | |
| 681 | .. versionadded:: 1.22.0 |
| 682 | |
| 683 | Returns |
| 684 | ------- |
| 685 | nansum : ndarray. |
| 686 | A new array holding the result is returned unless `out` is |
| 687 | specified, in which it is returned. The result has the same |
| 688 | size as `a`, and the same shape as `a` if `axis` is not None |
| 689 | or `a` is a 1-d array. |
| 690 | |
| 691 | See Also |
| 692 | -------- |
nothing calls this directly
no test coverage detected
searching dependent graphs…