X-Git-Url: https://svn.cri.ensmp.fr/git/linpy.git/blobdiff_plain/8332ae24f41a1f2bbba78597cc9e412ef9935ae8..b046bdcc9044a88743a98bb06951f917edafae59:/pypol/polyhedra.py diff --git a/pypol/polyhedra.py b/pypol/polyhedra.py index 69ed2b2..e745d7d 100644 --- a/pypol/polyhedra.py +++ b/pypol/polyhedra.py @@ -311,16 +311,18 @@ class Polyhedron(Domain): def _polymorphic(func): @functools.wraps(func) def wrapper(left, right): - if isinstance(left, numbers.Rational): - left = Rational(left) - elif not isinstance(left, Expression): - raise TypeError('left must be a a rational number ' - 'or a linear expression') - if isinstance(right, numbers.Rational): - right = Rational(right) - elif not isinstance(right, Expression): - raise TypeError('right must be a a rational number ' - 'or a linear expression') + if not isinstance(left, Expression): + 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, Expression): + 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) return wrapper