Skip to content

Commit 2e4b9fe

Browse files
authored
Update fuzzy_operations.py
1 parent a39e0dd commit 2e4b9fe

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

fuzzy_logic/fuzzy_operations.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from __future__ import annotations
22

33
from dataclasses import dataclass
4-
54
import matplotlib.pyplot as plt
65
import numpy as np
6+
77
@dataclass
88
class FuzzySet:
99
"""
@@ -15,7 +15,7 @@ class FuzzySet:
1515
right_boundary: float
1616

1717
def __str__(self) -> str:
18-
return f"{self.name}:[{self.left_boundary}, {self.peak}, {self.right_boundary}]"
18+
return f"{self.name}: [{self.left_boundary}, {self.peak}, {self.right_boundary}]"
1919

2020
def complement(self) -> FuzzySet:
2121
return FuzzySet(
@@ -39,7 +39,8 @@ def membership(self, x: float) -> float:
3939
elif self.left_boundary < x <= self.peak:
4040
return (x - self.left_boundary) / (self.peak - self.left_boundary)
4141
elif self.peak < x < self.right_boundary:
42-
return (self.right_boundary - x) / (self.right_boundary - self.peak)
42+
return (self.right_boundary - x) / (self.right_boundary - self.peak)
43+
4344
msg = f"Invalid value {x} for fuzzy set {self}"
4445
raise ValueError(msg)
4546

0 commit comments

Comments
 (0)