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

Method __add__

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

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 10

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
itemsMethod · 0.80
maxFunction · 0.50

Tested by

no test coverage detected