|
16 | 16 | import math |
17 | 17 | from itertools import chain |
18 | 18 | from operator import add, mul, truediv, sub, pow |
19 | | -from ..units import is_quantity, unit_of, to_unitless, is_quantity |
| 19 | +from ..units import is_quantity, unit_of, to_unitless |
20 | 20 | from .pyutil import defaultkeydict, deprecated |
21 | 21 |
|
22 | 22 |
|
@@ -213,10 +213,10 @@ def __call__(self, variables, backend=math, **kwargs): |
213 | 213 | raise NotImplementedError("Subclass and implement __call__") |
214 | 214 |
|
215 | 215 | def __float__(self): |
216 | | - try: |
217 | | - return float(self({})) |
218 | | - except KeyError: |
219 | | - raise ValueError("Missing values for variables") |
| 216 | + try: |
| 217 | + return float(self({})) |
| 218 | + except KeyError: |
| 219 | + raise ValueError("Missing values for variables") |
220 | 220 |
|
221 | 221 | def _all_keys(self, attr): |
222 | 222 | _keys = getattr(self, attr) |
@@ -534,9 +534,11 @@ def make(cls, arg, *args, **kwargs): |
534 | 534 | else: |
535 | 535 | return cls((arg,), *args, **kwargs) |
536 | 536 |
|
| 537 | + |
537 | 538 | class _NegExpr(_UnaryExpr): |
538 | 539 |
|
539 | | - _op = lambda x: -x |
| 540 | + def _op(x): |
| 541 | + return -x |
540 | 542 |
|
541 | 543 | def _str(self, *args, **kwargs): |
542 | 544 | return "-%s" % args[0]._str(*args, **kwargs) |
@@ -647,7 +649,6 @@ def __lt__(self, other): |
647 | 649 | return NotImplemented |
648 | 650 |
|
649 | 651 |
|
650 | | - |
651 | 652 | class Symbol(Expr): |
652 | 653 | nargs = 1 |
653 | 654 |
|
@@ -718,9 +719,9 @@ def _pw(bounds_exprs, x, backend=math, **kwargs): |
718 | 719 | upper = [bounds_exprs[2*(i+1)] for i in range(n_exprs)] |
719 | 720 | exprs = [bounds_exprs[2*i + 1] for i in range(n_exprs)] |
720 | 721 |
|
721 | | - |
722 | 722 | if is_quantity(x): |
723 | 723 | xunit = unit_of(x) |
| 724 | + |
724 | 725 | def ulx(arg): |
725 | 726 | return to_unitless(arg, xunit) |
726 | 727 | lower = list(map(ulx, lower)) |
|
0 commit comments