Skip to content

Commit a0d18a7

Browse files
committed
tests..
1 parent cb961f4 commit a0d18a7

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.hypothesis
12
.cache
23
__pycache__
34
.ipynb_checkpoints/

fuzzy/functions.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@
3232
from math import exp, log, sqrt
3333

3434

35+
def noop():
36+
"""Do nothing and return the value as is."""
37+
def f(x):
38+
return x
39+
return f
40+
3541
def inv(func):
3642
"""Invert the given function within the unit-interval.
3743
>>> f = inv(constant(0))

test_fuzzy_units.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33

44
from fuzzy import functions as fun
55

6+
7+
@given(st.floats(allow_nan=False, allow_infinity=False))
8+
def test_noop(x):
9+
f = fun.noop()
10+
assert f(x) == x
11+
12+
@given(st.floats(min_value=0, max_value=1))
13+
def test_invert(x):
14+
n = fun.noop()
15+
f = fun.inv(n)
16+
assert f(x) == 1 - x
17+
18+
619
@given(st.floats(min_value=0, max_value=1),
720
st.floats(min_value=0, max_value=1))
821
def test_constant(c, r):

0 commit comments

Comments
 (0)