Skip to content

Commit b72d10e

Browse files
committed
experimenting with rules..
1 parent d79a3d6 commit b72d10e

File tree

4 files changed

+103
-71
lines changed

4 files changed

+103
-71
lines changed

Showcase.ipynb

Lines changed: 90 additions & 70 deletions
Large diffs are not rendered by default.

fuzzy/classes.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ def __delattr__(self, name):
105105
else:
106106
raise FuzzyWarning("Trying to delete a regular attr, this needs extra care.")
107107

108+
def MIN(self, x):
109+
"""Standard way to get the min over all membership funcs.
110+
111+
It's not just more convenient but also faster than
112+
to calculate all results, construct a dict, unpack the dict
113+
and calculate the min from that.
114+
"""
115+
return min(f(x) for f in self._sets.values())
116+
108117
class Set:
109118
"""
110119
A fuzzyset defines a 'region' within a domain.

fuzzy/functions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ def gauss(c, b, *, c_m=1):
480480
defines the symmetry center/peak of the graph
481481
"""
482482
assert 0 < c_m <= 1
483-
assert 0 < b
483+
assert 0 < b, "b must be greater than 0"
484484

485485
def f(x):
486486
try:

fuzzy/rules.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
def scale(x, *, IN_min=0, IN_max=1, OUT_min, OUT_max):
3+
return (OUT_max - OUT_min)*(x - IN_min) / (IN_max - IN_min) + OUT_min

0 commit comments

Comments
 (0)