diff options
author | Stefanie Molin <24376333+stefmolin@users.noreply.github.com> | 2022-11-19 15:37:47 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-19 15:37:47 -0700 |
commit | 723f0eb315cfb16f913ddc4d9ac16bde738809f6 (patch) | |
tree | 621e1865316615738daaa7f481d12bc391e98d8a /numpy/ma/core.py | |
parent | cd757902af475c4844de878fbda25c70e2a0e66e (diff) | |
download | numpy-723f0eb315cfb16f913ddc4d9ac16bde738809f6.tar.gz |
DOC: Add example for np.ma.power as part of #22269
Diffstat (limited to 'numpy/ma/core.py')
-rw-r--r-- | numpy/ma/core.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 8c4ad37eb..91309bb3d 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -6900,6 +6900,32 @@ def power(a, b, third=None): The *out* argument to `numpy.power` is not supported, `third` has to be None. + Examples + -------- + >>> import numpy.ma as ma + >>> x = [11.2, -3.973, 0.801, -1.41] + >>> mask = [0, 0, 0, 1] + >>> masked_x = ma.masked_array(x, mask) + >>> masked_x + masked_array(data=[11.2, -3.973, 0.801, --], + mask=[False, False, False, True], + fill_value=1e+20) + >>> ma.power(masked_x, 2) + masked_array(data=[125.43999999999998, 15.784728999999999, + 0.6416010000000001, --], + mask=[False, False, False, True], + fill_value=1e+20) + >>> y = [-0.5, 2, 0, 17] + >>> masked_y = ma.masked_array(y, mask) + >>> masked_y + masked_array(data=[-0.5, 2.0, 0.0, --], + mask=[False, False, False, True], + fill_value=1e+20) + >>> ma.power(masked_x, masked_y) + masked_array(data=[0.29880715233359845, 15.784728999999999, 1.0, --], + mask=[False, False, False, True], + fill_value=1e+20) + """ if third is not None: raise MaskError("3-argument power not supported.") |