This is a pre-release version (latest). Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy latest / numpy / ma / core / sum

function

numpy.ma.core:sum

source: build-install/usr/lib/python3.14/site-packages/numpy/ma/core.py :7063

Summary

Return the sum of the array elements over the given axis.

Extended Summary

Masked elements are set to 0 internally.

Refer to numpy.sum for full documentation.

Examples

import numpy as np
x = np.ma.array([[1,2,3],[4,5,6],[7,8,9]], mask=[0] + [1,0]*4)
x
x.sum()
x.sum(axis=1)
x.sum(axis=0)
print(type(x.sum(axis=0, dtype=np.int64)[0]))

See also

numpy.ndarray.sum

corresponding function for ndarrays

numpy.sum

equivalent function

Aliases

  • numpy.ma.sum