From 7d26fd722aebdab5123d1c926b8b345669930ae9 Mon Sep 17 00:00:00 2001 From: Lafrite Date: Mon, 22 Dec 2014 11:44:14 +0100 Subject: [PATCH] add isNumerande into generic --- pymath/generic.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/pymath/generic.py b/pymath/generic.py index ae385c1..8f22345 100644 --- a/pymath/generic.py +++ b/pymath/generic.py @@ -335,6 +335,26 @@ def isPolynom(exp): return 0 return 1 +def isNumerande(exp): + """Check is the expression is something we can compute with + + >>> isNumerande(1) + 1 + >>> from pymath.polynom import Polynom + >>> p = Polynom([1,2]) + >>> isNumerande(p) + 1 + >>> from pymath.fraction import Fraction + >>> f = Fraction(12) + >>> isNumerande(f) + 1 + >>> isNumerande("a") + 0 + + + """ + return isNumber(exp) or isPolynom(exp) + if __name__ == '__main__': import doctest doctest.testmod()