diff --git a/pymath/calculus/expression.py b/pymath/calculus/expression.py index 99855fb..79e8ace 100644 --- a/pymath/calculus/expression.py +++ b/pymath/calculus/expression.py @@ -243,14 +243,15 @@ class Expression(Explicable): tmpTokenList += tokenList self.child = Expression(tmpTokenList) - steps = self.develop_steps(tmpTokenList) + steps = Expression.develop_steps(tmpTokenList) if self.child.postfix_tokens == ini_step.postfix_tokens: self.child.steps = steps else: self.child.this_append_before([ini_step] + steps) - def develop_steps(self, tokenList): + @classmethod + def develop_steps(cls, tokenList): """ From a list of tokens, it develops steps of each tokens """ tmp_steps = [] for t in tokenList: @@ -264,18 +265,15 @@ class Expression(Explicable): except AttributeError: tmp_steps.append([t]) - if max([len(i) for i in tmp_steps]) == 1: - # Cas où rien n'a dû être expliqué. - return [] - elif min([len(i) for i in tmp_steps]) == 0: - raise ValueError('tmp_steps: {} \ntokenList: {}'.format(tmp_steps, tokenList)) - else: + if max([len(i) for i in tmp_steps]) > 1: tmp_steps = expand_list(tmp_steps)[:-1] steps = [Expression(s) for s in tmp_steps] return steps + return [] + @classmethod - def isExpression(self, other): + def isExpression(cls, other): try: other._isExpression except AttributeError: