summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2022-11-19 17:52:31 -0600
committerGitHub <noreply@github.com>2022-11-19 17:52:31 -0600
commitea5735491b93020227703527b66121a673cc860a (patch)
tree621e1865316615738daaa7f481d12bc391e98d8a
parentcd757902af475c4844de878fbda25c70e2a0e66e (diff)
parent723f0eb315cfb16f913ddc4d9ac16bde738809f6 (diff)
downloadnumpy-ea5735491b93020227703527b66121a673cc860a.tar.gz
Merge pull request #22628 from stefmolin/patch-1
DOC: Add example for np.ma.power
-rw-r--r--numpy/ma/core.py26
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.")