(self, other)
| 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): |
nothing calls this directly
no test coverage detected