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
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:

View File

@ -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

View File

@ -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:

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -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]), "*",