MCPcopy Create free account
hub / github.com/numpy/numpy / __pow__

Method __pow__

numpy/f2py/symbolic.py:514–535  ·  view source on GitHub ↗
(self, other)

Source from the content-addressed store, hash-verified

512 return NotImplemented
513
514 def __pow__(self, other):
515 other = as_expr(other)
516 if isinstance(other, Expr):
517 if other.op is Op.INTEGER:
518 exponent = other.data[0]
519 # TODO: other kind not used
520 if exponent == 0:
521 return as_number(1)
522 if exponent == 1:
523 return self
524 if exponent > 0:
525 if self.op is Op.FACTORS:
526 r = Expr(self.op, {})
527 for k, v in self.data.items():
528 r.data[k] = v * exponent
529 return normalize(r)
530 return self * (self ** (exponent - 1))
531 elif exponent != -1:
532 return (self ** (-exponent)) ** -1
533 return Expr(Op.FACTORS, {self: exponent})
534 return as_apply(ArithOp.POW, self, other)
535 return NotImplemented
536
537 def __truediv__(self, other):
538 other = as_expr(other)

Callers

nothing calls this directly

Calls 6

as_exprFunction · 0.85
as_numberFunction · 0.85
ExprClass · 0.85
normalizeFunction · 0.85
as_applyFunction · 0.85
itemsMethod · 0.80

Tested by

no test coverage detected