66from fuzzy .classes import Domain , Set , Rule
77from fuzzy import functions as fun
88from fuzzy import hedges
9+ from fuzzy import combinators as combi
910
1011class Test_Functions (TestCase ):
1112 @given (st .floats (allow_nan = False ))
@@ -156,29 +157,116 @@ def test_triangular_sigmoid(self, x, low, high, c):
156157 st .floats (allow_nan = False , allow_infinity = False ),
157158 st .floats (min_value = 0 , max_value = 1 ))
158159 def test_gauss (self , x , b , c , c_m ):
159- assume (0 < c_m <= 1 )
160160 assume (0 < b )
161+ assume (0 < c_m )
161162 f = fun .gauss (c , b , c_m = c_m )
162163 assert (0 <= f (x ) <= 1 )
163164
164165class Test_Hedges (TestCase ):
165- @given (st .floats (allow_nan = False ))
166+ @given (st .floats (min_value = 0 , max_value = 1 ))
166167 def test_very (self , x ):
167- assume (0 <= x <= 1 )
168168 s = Set (fun .noop ())
169- h = hedges .very (s )
170- assert (0 <= h (x ) <= 1 )
171-
172- @given (st .floats (allow_nan = False ))
169+ f = hedges .very (s )
170+ assert (0 <= f (x ) <= 1 )
171+
172+ @given (st .floats (min_value = 0 , max_value = 1 ))
173173 def test_minus (self , x ):
174- assume (0 <= x <= 1 )
175174 s = Set (fun .noop ())
176- h = hedges .minus (s )
177- assert (0 <= h (x ) <= 1 )
175+ f = hedges .minus (s )
176+ assert (0 <= f (x ) <= 1 )
178177
179- @given (st .floats (allow_nan = False ))
178+ @given (st .floats (min_value = 0 , max_value = 1 ))
180179 def test_plus (self , x ):
181- assume (0 <= x <= 1 )
182180 s = Set (fun .noop ())
183- h = hedges .plus (s )
184- assert (0 <= h (x ) <= 1 )
181+ f = hedges .plus (s )
182+ assert (0 <= f (x ) <= 1 )
183+
184+
185+ class Test_Combinators (TestCase ):
186+ @given (st .floats (min_value = 0 , max_value = 1 ))
187+ def test_MIN (self , x ):
188+ a = fun .noop ()
189+ b = fun .noop ()
190+ f = combi .MIN (a , b )
191+ assert (0 <= f (x ) <= 1 )
192+
193+ @given (st .floats (min_value = 0 , max_value = 1 ))
194+ def test_MAX (self , x ):
195+ a = fun .noop ()
196+ b = fun .noop ()
197+ f = combi .MAX (a , b )
198+ assert (0 <= f (x ) <= 1 )
199+
200+ @given (st .floats (min_value = 0 , max_value = 1 ))
201+ def test_product (self , x ):
202+ a = fun .noop ()
203+ b = fun .noop ()
204+ f = combi .product (a , b )
205+ assert (0 <= f (x ) <= 1 )
206+
207+ @given (st .floats (min_value = 0 , max_value = 1 ))
208+ def test_bounded_sum (self , x ):
209+ a = fun .noop ()
210+ b = fun .noop ()
211+ f = combi .bounded_sum (a , b )
212+ assert (0 <= f (x ) <= 1 )
213+
214+ @given (st .floats (min_value = 0 , max_value = 1 ))
215+ def test_lukasiewicz_AND (self , x ):
216+ a = fun .noop ()
217+ b = fun .noop ()
218+ f = combi .lukasiewicz_AND (a , b )
219+ assert (0 <= f (x ) <= 1 )
220+
221+ @given (st .floats (min_value = 0 , max_value = 1 ))
222+ def test_lukasiewicz_OR (self , x ):
223+ a = fun .noop ()
224+ b = fun .noop ()
225+ f = combi .lukasiewicz_OR (a , b )
226+ assert (0 <= f (x ) <= 1 )
227+
228+ @given (st .floats (min_value = 0 , max_value = 1 ))
229+ def test_einstein_product (self , x ):
230+ a = fun .noop ()
231+ b = fun .noop ()
232+ f = combi .einstein_product (a , b )
233+ assert (0 <= f (x ) <= 1 )
234+
235+ @given (st .floats (min_value = 0 , max_value = 1 ))
236+ def test_einstein_sum (self , x ):
237+ a = fun .noop ()
238+ b = fun .noop ()
239+ f = combi .einstein_sum (a , b )
240+ assert (0 <= f (x ) <= 1 )
241+
242+ @given (st .floats (min_value = 0 , max_value = 1 ))
243+ def test_hamacher_product (self , x ):
244+ a = fun .noop ()
245+ b = fun .noop ()
246+ f = combi .hamacher_product (a , b )
247+ assert (0 <= f (x ) <= 1 )
248+
249+ @given (st .floats (min_value = 0 , max_value = 1 ))
250+ def test_hamacher_sum (self , x ):
251+ a = fun .noop ()
252+ b = fun .noop ()
253+ f = combi .hamacher_sum (a , b )
254+ assert (0 <= f (x ) <= 1 )
255+
256+ @given (st .floats (min_value = 0 , max_value = 1 ),
257+ st .floats (min_value = 0 , max_value = 1 ))
258+ def test_lambda_op (self , x , l ):
259+ a = fun .noop ()
260+ b = fun .noop ()
261+ g = combi .lambda_op (l )
262+ f = g (a , b )
263+ assert (0 <= f (x ) <= 1 )
264+
265+ @given (st .floats (min_value = 0 , max_value = 1 ),
266+ st .floats (min_value = 0 , max_value = 1 ))
267+ def test_gamma_op (self , x , g ):
268+ a = fun .noop ()
269+ b = fun .noop ()
270+ g = combi .gamma_op (g )
271+ f = g (a , b )
272+ assert (0 <= f (x ) <= 1 )
0 commit comments