Commits

tomo cocoa committed dfbb010

pep8

Comments (0)

Files changed (4)

 a ∈ A may not know how the addition is processed, but
 b ∈ B should know how.
 
-If a.__add__(b) fails, In this code, b.__radd__(a) is called and must not throw an exception.
+If a.__add__(b) fails, In this code, b.__radd__(a) is called and must not
+throw an exception.
 b.__radd__(a) can throw TypeError.
 """
 
 from base import Element
 from six import with_metaclass
 
+
 class Group(with_metaclass(ABCMeta, base=Element)):
 
     @abstractmethod
 class AbelianGroup(Group):
     pass
 
+
 class Integer(AbelianGroup):
 
     @staticmethod
         raise TypeError('the argument "integer" is in a type of {0} '
                         'and its value is "{1}". '
                         'it must be in a type of either {2}, {3} or {4}'
-                        .format(type(integer), integer, Rational, Integer, int))
+                        .format(type(integer), integer, Rational, Integer, int)
+                        )
 
     def __init__(self, numerator=0, denominator=1):
         assert not denominator == 0
 
     def __add__(self, other):
         if type(self) == type(other):
-            return self.__class__(self.numerator * other.denominator + \
-                                      self.denominator * other.numerator, 
+            return self.__class__(self.numerator * other.denominator +
+                                  self.denominator * other.numerator,
                                   self.denominator * other.denominator)
         try:
             return self + Rational.as_Rational(other)

logics/numeric.py

+#!/usr/local/bin/python
+# -*- coding: utf-8 -*-
+
 import base
 from six import with_metaclass
 
+
 def pretty_print(prop):
 
     if type(prop) == Var:
         return prop
     elif type(prop) == Not:
         child = sink_Not(prop.child)
-        if type(child) == Constant: #1
+        if type(child) == Constant: # 1
             if child:
                 return F
             else:
                 return T
-        elif type(child) == Var: #2
+        elif type(child) == Var: # 2
             return Not(child)
-        elif type(child) == Not: #3
+        elif type(child) == Not: # 3
             return child.child
-        elif type(child) == Or: #4
+        elif type(child) == Or: # 4
             return And(sink_Not(Not(child.left)),
                        sink_Not(Not(child.right)))
-        elif type(child) == And: #5
+        elif type(child) == And: # 5
             return Or(sink_Not(Not(child.left)),
                       sink_Not(Not(child.right)))
         else:
         elif type(prop) == And:
             left = sink_And(prop.left)
             right = sink_And(prop.right)
-            if type(left) == Or: #10
+            if type(left) == Or: # 10
                 return Or(sink_And(And(left.left, right)),
                           sink_And(And(left.right, right)))
-            elif type(right) == Or: #11
+            elif type(right) == Or: # 11
                 return Or(sink_And(And(left, right.left)),
                           sink_And(And(left, right.right)))
-            elif type(left) == And: #12
+            elif type(left) == And: # 12
                 return And(left.left, sink_And(And(left.right, right)))
             else:
                 return And(left, right)
         elif type(prop) == Or:
             return Or(sink_And(prop.left), sink_And(prop.right))
-        else: #1, #2
+        else: # 1, 2
             raise TypeError('type "{0}" is not supported.'
                             .format(type(prop)))
 
         elif type(prop) == Or:
             left = sink_Or(prop.left)
             right = sink_Or(prop.right)
-            if type(left) == And: #10
+            if type(left) == And: # 10
                 return And(sink_Or(Or(left.left, right)),
                            sink_Or(Or(left.right, right)))
-            elif type(right) == And: #11
+            elif type(right) == And: # 11
                 return And(sink_Or(Or(left, right.left)),
                            sink_Or(Or(left, right.right)))
-            elif type(left) == Or: #12
+            elif type(left) == Or: # 12
                 return Or(left.left, sink_Or(Or(left.right, right)))
-            else: #1, #2
+            else: # 1, 2
                 return Or(left, right)
         elif type(prop) == And:
             return And(sink_Or(prop.left), sink_Or(prop.right))
             raise TypeError('type "{0}" is not supported.'
                             .format(type(prop)))
 
-
     def order_And(prop):
         if _is_primitive(prop):
             return prop
         else:
             raise TypeError('type "{0}" is not supported.'
                             .format(type(prop)))
-            
+
     return order_And(sink_Or(sink_Not(replace_with_And_Or_Not(prop))))
 
 
                 elif dnf.left == F:
                     return F
                 else:
-                    raise ValueError('Prop: {0} is not acceptable.'.format(dnf))
+                    raise ValueError('Prop: {0} is not acceptable.'
+                                     .format(dnf))
 
             var = Var(dnf.varnames[0])
             positive = canonicalize(filter_literal(var, dnf))
                 elif cnf.left == F:
                     return F
                 else:
-                    raise ValueError('Prop: {0} is not acceptable.'.format(cnf))
+                    raise ValueError('Prop: {0} is not acceptable.'
+                                     .format(cnf))
 
             var = Var(cnf.varnames[0])
             positive = canonicalize(filter_literal(var, cnf))
 import group
 import logics.prop as lp
 
+
 class Ring(group.Group):
 
     @abstractmethod
         raise TypeError('the argument "integer" is in a type of {0} '
                         'and its value is "{1}". '
                         'it must be in a type of either {2}, {3} or {4}'
-                        .format(type(integer), integer, Rational, Integer, int))
+                        .format(type(integer), integer, Rational, Integer, int)
+                        )
 
     def __repr__(self):
         return '<ring.Rational numerator: {0}, denominator: {1}>' \