From 698fea5c63e61ae579fbe6f60a274882db509de8 Mon Sep 17 00:00:00 2001 From: lafrite Date: Tue, 28 Jan 2014 23:21:37 +0100 Subject: [PATCH] generate letters can't be equal to 0 --- pymath/random_expression.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pymath/random_expression.py b/pymath/random_expression.py index d898f72..253db8a 100644 --- a/pymath/random_expression.py +++ b/pymath/random_expression.py @@ -84,6 +84,8 @@ class RdExpression(object): """ for l in self._letters: self._gene_varia[l] = randint(val_min, val_max) + while self._gene_varia[l] == 0: + self._gene_varia[l] = randint(val_min, val_max) for e in self._2replaced: self._gene_2replaced[e] = eval(e, globals(), self._gene_varia) @@ -123,7 +125,7 @@ if __name__ == '__main__': #desc_rdExp(rdExp3) form1 = "{a**2}x^2 + {2*a*b}x + {b**2}" - cond1 = ["{a} != 0", "{b} != 0"] + cond1 = [] rdExp1 = RdExpression(form1, cond1) desc_rdExp(rdExp1)