diff --git a/pymath/calculus/operator/par.py b/pymath/calculus/operator/par.py index 4977c58..6d07969 100644 --- a/pymath/calculus/operator/par.py +++ b/pymath/calculus/operator/par.py @@ -4,24 +4,22 @@ from .operator import Operator + class Par(Operator): """ The operator ( """ _CARACT = { - "operator" : "(", \ - "name" : "par",\ - "priority" : 0, \ - "arity" : 0, \ + "operator": "(", + "name": "par", + "priority": 0, + "arity": 0, } def __init__(self): """ Initiate Par Operator """ super(Par, self).__init__(**self._CARACT) - - - # ----------------------------- # Reglages pour 'vim' # vim:set autoindent expandtab tabstop=4 shiftwidth=4: diff --git a/pymath/calculus/operator/pw.py b/pymath/calculus/operator/pw.py index 5d2d1d3..1b83d65 100644 --- a/pymath/calculus/operator/pw.py +++ b/pymath/calculus/operator/pw.py @@ -5,6 +5,7 @@ from .operator import Operator from ..generic import flatten_list + class Pw(Operator): """ The operator ^ @@ -29,13 +30,13 @@ class Pw(Operator): """ _CARACT = { - "operator" : "^", \ - "name" : "pw",\ - "priority" : 6, \ - "arity" : 2, \ - "actions" : ("__pow__",""), \ - "txt" : "{op1} ^ {op2}",\ - "tex" : "{op1}^{{ {op2} }}",\ + "operator": "^", + "name": "pw", + "priority": 6, + "arity": 2, + "actions": ("__pow__", ""), + "txt": "{op1} ^ {op2}", + "tex": "{op1}^{{ {op2} }}", } def __init__(self): @@ -52,7 +53,7 @@ class Pw(Operator): try: if opl.mainOp.priority < self.priority: ans = flatten_list(["(", opl, ")"]) - except AttributeError as e: + except AttributeError: # op has not the attribute priority pass try: @@ -75,7 +76,7 @@ class Pw(Operator): """ op1 = self.l_parenthesis(args[0], True) op2 = args[1] - ans = self.tex.format(op1 = op1, op2 = op2) + ans = self.tex.format(op1=op1, op2=op2) return ans diff --git a/pymath/calculus/operator/sub.py b/pymath/calculus/operator/sub.py index 4dd7c7f..2bc2c8c 100644 --- a/pymath/calculus/operator/sub.py +++ b/pymath/calculus/operator/sub.py @@ -5,6 +5,7 @@ from .operator import Operator from ..generic import flatten_list + class Sub(Operator): """ The operator - @@ -28,13 +29,13 @@ class Sub(Operator): '-1 - 2' """ _CARACT = { - "operator" : "-", \ - "name" : "sub",\ - "priority" : 2, \ - "arity" : 2, \ - "actions" : ("__sub__","__rsub__"), \ - "txt" : "{op1} - {op2}",\ - "tex" : "{op1} - {op2}",\ + "operator": "-", + "name": "sub", + "priority": 2, + "arity": 2, + "actions": ("__sub__", "__rsub__"), + "txt": "{op1} - {op2}", + "tex": "{op1} - {op2}", } def __init__(self): @@ -62,12 +63,6 @@ class Sub(Operator): ans = ' '.join([str(i) for i in ans]) return ans - - - - - - # ----------------------------- # Reglages pour 'vim' # vim:set autoindent expandtab tabstop=4 shiftwidth=4: diff --git a/pymath/calculus/operator/sub1.py b/pymath/calculus/operator/sub1.py index 49ccd2e..e4e9447 100644 --- a/pymath/calculus/operator/sub1.py +++ b/pymath/calculus/operator/sub1.py @@ -5,6 +5,7 @@ from .operator import Operator from ..generic import flatten_list + class Sub1(Operator): """ The operator - @@ -25,13 +26,13 @@ class Sub1(Operator): """ _CARACT = { - "operator" : "-", \ - "name" : "sub1",\ - "priority" : 3, \ - "arity" : 1, \ - "actions" : "__neg__",\ - "txt" : "- {op1}",\ - "tex" : "- {op1}",\ + "operator": "-", + "name": "sub1", + "priority": 3, + "arity": 1, + "actions": "__neg__", + "txt": "- {op1}", + "tex": "- {op1}", } def __init__(self): diff --git a/pymath/calculus/test/test_expression.py b/pymath/calculus/test/test_expression.py index cc34e0f..b9ebfe4 100644 --- a/pymath/calculus/test/test_expression.py +++ b/pymath/calculus/test/test_expression.py @@ -5,9 +5,6 @@ from pymath.calculus.expression import Expression -from pymath.calculus.fraction import Fraction -from pymath.calculus.generic import first_elem -from pymath.calculus.render import txt, tex from pymath.calculus.operator import op diff --git a/pymath/calculus/test/test_render.py b/pymath/calculus/test/test_render.py index 923366e..e8c40af 100644 --- a/pymath/calculus/test/test_render.py +++ b/pymath/calculus/test/test_render.py @@ -4,7 +4,7 @@ import unittest -from pymath.calculus.render import tex, txt, p2i +from pymath.calculus.render import tex, txt from pymath.calculus.fraction import Fraction from pymath.calculus.polynom import Polynom from pymath.calculus.operator import op diff --git a/pymath/calculus/test/test_str2tokens.py b/pymath/calculus/test/test_str2tokens.py index 213bd2f..361f26a 100644 --- a/pymath/calculus/test/test_str2tokens.py +++ b/pymath/calculus/test/test_str2tokens.py @@ -57,7 +57,7 @@ class TestStr2tokens(unittest.TestCase): post = str2in_tokens(exp) self.assertEqual(post, [Polynom([0, 1]), "*", Polynom([0, 1]), '+', 4]) - def test_str2tokens_poly(self): + def test_str2tokens_poly_par(self): exp = "x(2+1) + 4" post = str2in_tokens(exp) self.assertEqual(post, [Polynom([0, 1]), "*",