MCPcopy Index your code
hub / github.com/numpy/numpy / power

Function power

numpy/ma/core.py:7134–7210  ·  view source on GitHub ↗

Returns element-wise base array raised to power from second array. This is the masked array version of `numpy.power`. For details see `numpy.power`. See Also -------- numpy.power Notes ----- The *out* argument to `numpy.power` is not supported, `third` has to

(a, b, third=None)

Source from the content-addressed store, hash-verified

7132
7133
7134def power(a, b, third=None):
7135 """
7136 Returns element-wise base array raised to power from second array.
7137
7138 This is the masked array version of `numpy.power`. For details see
7139 `numpy.power`.
7140
7141 See Also
7142 --------
7143 numpy.power
7144
7145 Notes
7146 -----
7147 The *out* argument to `numpy.power` is not supported, `third` has to be
7148 None.
7149
7150 Examples
7151 --------
7152 >>> import numpy as np
7153 >>> import numpy.ma as ma
7154 >>> x = [11.2, -3.973, 0.801, -1.41]
7155 >>> mask = [0, 0, 0, 1]
7156 >>> masked_x = ma.masked_array(x, mask)
7157 >>> masked_x
7158 masked_array(data=[11.2, -3.973, 0.801, --],
7159 mask=[False, False, False, True],
7160 fill_value=1e+20)
7161 >>> ma.power(masked_x, 2)
7162 masked_array(data=[125.43999999999998, 15.784728999999999,
7163 0.6416010000000001, --],
7164 mask=[False, False, False, True],
7165 fill_value=1e+20)
7166 >>> y = [-0.5, 2, 0, 17]
7167 >>> masked_y = ma.masked_array(y, mask)
7168 >>> masked_y
7169 masked_array(data=[-0.5, 2.0, 0.0, --],
7170 mask=[False, False, False, True],
7171 fill_value=1e+20)
7172 >>> ma.power(masked_x, masked_y)
7173 masked_array(data=[0.2988071523335984, 15.784728999999999, 1.0, --],
7174 mask=[False, False, False, True],
7175 fill_value=1e+20)
7176
7177 """
7178 if third is not None:
7179 raise MaskError("3-argument power not supported.")
7180 # Get the masks
7181 ma = getmask(a)
7182 mb = getmask(b)
7183 m = mask_or(ma, mb)
7184 # Get the rawdata
7185 fa = getdata(a)
7186 fb = getdata(b)
7187 # Get the type of the result (so that we preserve subclasses)
7188 if isinstance(a, MaskedArray):
7189 basetype = type(a)
7190 else:
7191 basetype = MaskedArray

Callers 3

test_powerMethod · 0.90
__pow__Method · 0.70
__rpow__Method · 0.70

Calls 7

MaskErrorClass · 0.85
getmaskFunction · 0.85
mask_orFunction · 0.85
getdataFunction · 0.85
_update_fromMethod · 0.80
viewMethod · 0.45
anyMethod · 0.45

Tested by 1

test_powerMethod · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…