finish corr flake8 in calculus

This commit is contained in:
Benjamin Bertrand 2016-03-07 08:48:21 +03:00
parent edd83fe56a
commit b241142976
7 changed files with 33 additions and 41 deletions

View File

@ -4,24 +4,22 @@
from .operator import Operator from .operator import Operator
class Par(Operator): class Par(Operator):
""" The operator ( """ """ The operator ( """
_CARACT = { _CARACT = {
"operator" : "(", \ "operator": "(",
"name" : "par",\ "name": "par",
"priority" : 0, \ "priority": 0,
"arity" : 0, \ "arity": 0,
} }
def __init__(self): def __init__(self):
""" Initiate Par Operator """ """ Initiate Par Operator """
super(Par, self).__init__(**self._CARACT) super(Par, self).__init__(**self._CARACT)
# ----------------------------- # -----------------------------
# Reglages pour 'vim' # Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4: # vim:set autoindent expandtab tabstop=4 shiftwidth=4:

View File

@ -5,6 +5,7 @@
from .operator import Operator from .operator import Operator
from ..generic import flatten_list from ..generic import flatten_list
class Pw(Operator): class Pw(Operator):
""" The operator ^ """ The operator ^
@ -29,13 +30,13 @@ class Pw(Operator):
""" """
_CARACT = { _CARACT = {
"operator" : "^", \ "operator": "^",
"name" : "pw",\ "name": "pw",
"priority" : 6, \ "priority": 6,
"arity" : 2, \ "arity": 2,
"actions" : ("__pow__",""), \ "actions": ("__pow__", ""),
"txt" : "{op1} ^ {op2}",\ "txt": "{op1} ^ {op2}",
"tex" : "{op1}^{{ {op2} }}",\ "tex": "{op1}^{{ {op2} }}",
} }
def __init__(self): def __init__(self):
@ -52,7 +53,7 @@ class Pw(Operator):
try: try:
if opl.mainOp.priority < self.priority: if opl.mainOp.priority < self.priority:
ans = flatten_list(["(", opl, ")"]) ans = flatten_list(["(", opl, ")"])
except AttributeError as e: except AttributeError:
# op has not the attribute priority # op has not the attribute priority
pass pass
try: try:

View File

@ -5,6 +5,7 @@
from .operator import Operator from .operator import Operator
from ..generic import flatten_list from ..generic import flatten_list
class Sub(Operator): class Sub(Operator):
""" The operator - """ The operator -
@ -28,13 +29,13 @@ class Sub(Operator):
'-1 - 2' '-1 - 2'
""" """
_CARACT = { _CARACT = {
"operator" : "-", \ "operator": "-",
"name" : "sub",\ "name": "sub",
"priority" : 2, \ "priority": 2,
"arity" : 2, \ "arity": 2,
"actions" : ("__sub__","__rsub__"), \ "actions": ("__sub__", "__rsub__"),
"txt" : "{op1} - {op2}",\ "txt": "{op1} - {op2}",
"tex" : "{op1} - {op2}",\ "tex": "{op1} - {op2}",
} }
def __init__(self): def __init__(self):
@ -62,12 +63,6 @@ class Sub(Operator):
ans = ' '.join([str(i) for i in ans]) ans = ' '.join([str(i) for i in ans])
return ans return ans
# ----------------------------- # -----------------------------
# Reglages pour 'vim' # Reglages pour 'vim'
# vim:set autoindent expandtab tabstop=4 shiftwidth=4: # vim:set autoindent expandtab tabstop=4 shiftwidth=4:

View File

@ -5,6 +5,7 @@
from .operator import Operator from .operator import Operator
from ..generic import flatten_list from ..generic import flatten_list
class Sub1(Operator): class Sub1(Operator):
""" The operator - """ The operator -
@ -25,13 +26,13 @@ class Sub1(Operator):
""" """
_CARACT = { _CARACT = {
"operator" : "-", \ "operator": "-",
"name" : "sub1",\ "name": "sub1",
"priority" : 3, \ "priority": 3,
"arity" : 1, \ "arity": 1,
"actions" : "__neg__",\ "actions": "__neg__",
"txt" : "- {op1}",\ "txt": "- {op1}",
"tex" : "- {op1}",\ "tex": "- {op1}",
} }
def __init__(self): def __init__(self):

View File

@ -5,9 +5,6 @@
from pymath.calculus.expression import Expression 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 from pymath.calculus.operator import op

View File

@ -4,7 +4,7 @@
import unittest 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.fraction import Fraction
from pymath.calculus.polynom import Polynom from pymath.calculus.polynom import Polynom
from pymath.calculus.operator import op from pymath.calculus.operator import op

View File

@ -57,7 +57,7 @@ class TestStr2tokens(unittest.TestCase):
post = str2in_tokens(exp) post = str2in_tokens(exp)
self.assertEqual(post, [Polynom([0, 1]), "*", Polynom([0, 1]), '+', 4]) 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" exp = "x(2+1) + 4"
post = str2in_tokens(exp) post = str2in_tokens(exp)
self.assertEqual(post, [Polynom([0, 1]), "*", self.assertEqual(post, [Polynom([0, 1]), "*",