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