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

Method __add__

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

Source from the content-addressed store, hash-verified

426 return self * -1
427
428 def __add__(self, other):
429 other = as_expr(other)
430 if isinstance(other, Expr):
431 if self.op is other.op:
432 if self.op in (Op.INTEGER, Op.REAL):
433 return as_number(
434 self.data[0] + other.data[0],
435 max(self.data[1], other.data[1]))
436 if self.op is Op.COMPLEX:
437 r1, i1 = self.data
438 r2, i2 = other.data
439 return as_complex(r1 + r2, i1 + i2)
440 if self.op is Op.TERMS:
441 r = Expr(self.op, dict(self.data))
442 for k, v in other.data.items():
443 _pairs_add(r.data, k, v)
444 return normalize(r)
445 if self.op is Op.COMPLEX and other.op in (Op.INTEGER, Op.REAL):
446 return self + as_complex(other)
447 elif self.op in (Op.INTEGER, Op.REAL) and other.op is Op.COMPLEX:
448 return as_complex(self) + other
449 elif self.op is Op.REAL and other.op is Op.INTEGER:
450 return self + as_real(other, kind=self.data[1])
451 elif self.op is Op.INTEGER and other.op is Op.REAL:
452 return as_real(self, kind=other.data[1]) + other
453 return as_terms(self) + as_terms(other)
454 return NotImplemented
455
456 def __radd__(self, other):
457 if isinstance(other, number_types):

Callers

nothing calls this directly

Calls 9

as_exprFunction · 0.85
as_numberFunction · 0.85
as_complexFunction · 0.85
ExprClass · 0.85
_pairs_addFunction · 0.85
normalizeFunction · 0.85
as_realFunction · 0.85
as_termsFunction · 0.85
maxFunction · 0.50

Tested by

no test coverage detected