@@ -25,10 +25,11 @@ def __or__(self, other):
2525 return OR (self , other )
2626
2727 def __repr__ (self ):
28- return ' {0}({1})' .format (self .__class__ .__name__ , self .__dict__ )
28+ return " {0}({1})" .format (self .__class__ .__name__ , self .__dict__ )
2929
3030 def __str__ (self ):
31- return '{0}({1})' .format (self .__class__ .__name__ , self .__dict__ )
31+ return "{0}({1})" .format (self .__class__ .__name__ , self .__dict__ )
32+
3233
3334# These basic operators are defined here to avoid an import-loop
3435
@@ -83,7 +84,7 @@ def __init__(self, name, limits, resolution=1.0):
8384 """
8485 # the fuzzysets as attributes
8586 self .sets = {}
86- assert limits [0 ] <= limits [1 ], ' Lower limit > upper limit!'
87+ assert limits [0 ] <= limits [1 ], " Lower limit > upper limit!"
8788 self .name = name
8889 self .limits = limits
8990 self .resolution = resolution
@@ -100,23 +101,22 @@ def __getattr__(self, name):
100101
101102 def __setattr__ (self , name , fuzzyfunc ):
102103 # it's not actually a fuzzyfunc but a domain attr
103- if name in [' name' , ' limits' , ' resolution' , ' sets' ]:
104+ if name in [" name" , " limits" , " resolution" , " sets" ]:
104105 object .__setattr__ (self , name , fuzzyfunc )
105106 # we've got a fuzzyset within this domain defined by a fuzzyfunc
106107 else :
107108 self .sets [name ] = fuzzyfunc
108109
109110 def plot (self ):
110- r = arange (self .limits [0 ], self .limits [1 ] + self .resolution ,
111- self .resolution )
111+ r = arange (self .limits [0 ], self .limits [1 ] + self .resolution , self .resolution )
112112 for s in self .sets .values ():
113- print (r , s )
113+ print (r , s )
114114 # plot(s(r))
115115 # show()
116116
117117 def __call__ (self , x ):
118118 for name , f in self .sets .items ():
119- print (name , f (x ))
119+ print (name , f (x ))
120120
121121
122122class Rule (object ):
@@ -132,8 +132,7 @@ class Rule(object):
132132 as a function.
133133 """
134134
135- def __init__ (self , IF , THEN , believe = 1 ,
136- and_ = None , or_ = None , not_ = None , inference_ = None ):
135+ def __init__ (self , IF , THEN , believe = 1 , and_ = None , or_ = None , not_ = None , inference_ = None ):
137136 """The core fuzzy logic.
138137
139138 IF is a string representing a condition using qualified fuzzy sets
@@ -166,11 +165,10 @@ def __call__(self):
166165
167166
168167if __name__ == "__main__" :
169-
170168 import cProfile
171169 from timeit import Timer
172170
173- import . fuzzification as fuzzy
171+ from . import fuzzification as fuzzy
174172
175173 temp = 25
176174 month = 9
@@ -188,14 +186,15 @@ def definition():
188186 def call ():
189187 return a (8.6 )
190188
191- cProfile .run (' definition()' )
192- print (Timer (definition ).timeit ())
189+ cProfile .run (" definition()" )
190+ print (Timer (definition ).timeit ())
193191
194- cProfile .run (' call' )
195- print (Timer (call ).timeit ())
192+ cProfile .run (" call" )
193+ print (Timer (call ).timeit ())
196194
197195 temp = Domain ("temperature" , limits = (0 , 100 ))
198196 temp .hot = fuzzy .linear (5 , 35 )
199197
200198 import doctest
199+
201200 doctest .testmod ()
0 commit comments