From 85d5b935d920f6bb8999e7f3ae73860a01b50dbd Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Fri, 9 May 2014 23:21:42 -0300 Subject: [PATCH] PEP8 traits --- pymbolic/traits.py | 34 ++++++++++------------------------ 1 file changed, 10 insertions(+), 24 deletions(-) diff --git a/pymbolic/traits.py b/pymbolic/traits.py index 8cbff25..bbcc854 100644 --- a/pymbolic/traits.py +++ b/pymbolic/traits.py @@ -25,17 +25,14 @@ THE SOFTWARE. import algorithm - - class NoTraitsError(Exception): pass + class NoCommonTraitsError(Exception): pass - - def traits(x): try: return x.traits() @@ -55,46 +52,40 @@ def common_traits(*args): elif isinstance(t_x, t_y.__class__): return t_x else: - raise NoCommonTraitsError, \ - "No common traits type between '%s' and '%s'" % \ - (t_x.__class__.__name__, t_y.__class__.__name__) + raise NoCommonTraitsError( + "No common traits type between '%s' and '%s'" % + (t_x.__class__.__name__, t_y.__class__.__name__)) return reduce(common_traits_two, (traits(arg) for arg in args)) - - class Traits(object): pass - - class IntegralDomainTraits(Traits): pass - - class EuclideanRingTraits(IntegralDomainTraits): @classmethod def norm(cls, x): """Returns the algebraic norm of the element x. - + "Norm" is used as in the definition of a Euclidean ring, see [Bosch], p. 42 """ raise NotImplementedError @staticmethod - def gcd_extended(q, r): - """Return a tuple (p, a, b) such that p = aq + br, + def gcd_extended(q, r): + """Return a tuple (p, a, b) such that p = aq + br, where p is the greatest common divisor. """ return algorithm.extended_euclidean(q, r) - + @staticmethod - def gcd(q, r): + def gcd(q, r): """Returns the greatest common divisor of q and r. """ return algorithm.extended_euclidean(q, r)[0] @@ -112,14 +103,10 @@ class EuclideanRingTraits(IntegralDomainTraits): raise NotImplementedError - - class FieldTraits(IntegralDomainTraits): pass - - class IntegerTraits(EuclideanRingTraits): @staticmethod def norm(x): @@ -132,5 +119,4 @@ class IntegerTraits(EuclideanRingTraits): elif x > 0: return 1 else: - raise RuntimeError, "0 does not have a prime factor decomposition" - + raise RuntimeError("0 does not have a prime factor decomposition") -- GitLab