- def wrapper(left, right):
- if not isinstance(left, LinExpr):
- if isinstance(left, numbers.Rational):
- left = Rational(left)
- else:
- raise TypeError('left must be a a rational number '
- 'or a linear expression')
- if not isinstance(right, LinExpr):
- if isinstance(right, numbers.Rational):
- right = Rational(right)
- else:
- raise TypeError('right must be a a rational number '
- 'or a linear expression')
- return func(left, right)
+ def wrapper(expr1, expr2, *exprs):
+ exprs = (expr1, expr2) + exprs
+ for expr in exprs:
+ if not isinstance(expr, LinExpr):
+ if isinstance(expr, numbers.Rational):
+ expr = Rational(expr)
+ else:
+ raise TypeError('arguments must be rational numbers '
+ 'or linear expressions')
+ return func(*exprs)