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

Method __pow__

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 5

as_exprFunction · 0.85
as_numberFunction · 0.85
ExprClass · 0.85
normalizeFunction · 0.85
as_applyFunction · 0.85

Tested by

no test coverage detected