From 1b4411894a18995f7fc710bf76bc4b30bcb3d5e1 Mon Sep 17 00:00:00 2001 From: Simone Spolaor Date: Tue, 31 May 2022 16:06:40 +0200 Subject: [PATCH] support for unicode characters and bug fix --- setup.py | 2 +- simpful/rule_parsing.py | 4 ++-- simpful/simpful.py | 7 +++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/setup.py b/setup.py index f389253..aadf2c8 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ setup( name = 'simpful', packages = ['simpful'], # this must be the same as the name above - version = '2.6.3', + version = '2.6.4', description = 'A user-friendly Python library for fuzzy logic', author = 'Marco S. Nobile', author_email = 'marco.nobile@unive.it', diff --git a/simpful/rule_parsing.py b/simpful/rule_parsing.py index e8229d3..08b8b3b 100644 --- a/simpful/rule_parsing.py +++ b/simpful/rule_parsing.py @@ -1,8 +1,8 @@ import re from numpy import array -regex_clause_with_parentheses = re.compile(r"^\([a-z,_,A-Z,0-9]*\s*IS\s*[a-z,_,A-Z,0-9]*\)$") -regex_clause = re.compile(r"^[a-z,_,A-Z,0-9]*\s*IS\s*[a-z,_,A-Z,0-9]*$") +regex_clause_with_parentheses = re.compile(r"^\(\w*\s*IS\s*\w*\)$") +regex_clause = re.compile(r"^\w*\s*IS\s*\w*$") class Clause(object): diff --git a/simpful/simpful.py b/simpful/simpful.py index 417f1da..fd7d264 100644 --- a/simpful/simpful.py +++ b/simpful/simpful.py @@ -120,7 +120,6 @@ def draw(self, ax, TGT=None, highlight=None, xscale="linear"): for nn, fs in enumerate(self._FSlist): if isinstance(fs, SingletonsSet): - print(fs._funpointer._pairs) xs = [pair[0] for pair in fs._funpointer._pairs] ys = [pair[1] for pair in fs._funpointer._pairs] ax.vlines(x=xs, ymin=0.0, ymax=ys, linestyles=linestyles[nn%4], color=next(ax._get_lines.prop_cycler)['color'], label=fs._term) @@ -143,7 +142,7 @@ def draw(self, ax, TGT=None, highlight=None, xscale="linear"): ax.axvline(x=TGT, ymin=0.0, ymax=1.0, color="red", linestyle="--", linewidth=2.0) ax.set_xlabel(self._concept) ax.set_ylabel("Membership degree") - ax.set_ylim(bottom=-0.05) + ax.set_ylim(bottom=-0.05, top=1.05) if xscale == "log": ax.set_xscale("symlog", linthresh=10e-2) ax.set_xlim(x[0], x[-1]) @@ -626,7 +625,7 @@ def Sugeno_inference(self, terms=None, ignore_errors=False, ignore_warnings=Fals Returns: a dictionary, containing as keys the variables' names and as values their numerical inferred values. """ - if self._sanitize and terms is not None: + if self._sanitize_input and terms is not None: terms = [self._sanitize(term) for term in terms] # default: inference on ALL rules/terms @@ -669,7 +668,7 @@ def Mamdani_inference(self, terms=None, subdivisions=1000, ignore_errors=False, Returns: a dictionary, containing as keys the variables' names and as values their numerical inferred values. """ - if self._sanitize and terms is not None: + if self._sanitize_input and terms is not None: terms = [self._sanitize(term) for term in terms] # default: inference on ALL rules/terms