Skip to content

Commit 3cf5a9d

Browse files
authored
Update fuzzy_operations.py
1 parent 4af9b1f commit 3cf5a9d

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

fuzzy_logic/fuzzy_operations.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import annotations
2+
23
from dataclasses import dataclass
34
import matplotlib.pyplot as plt
45
import numpy as np
@@ -39,7 +40,10 @@ def membership(self, x: float) -> float:
3940
return (x - self.left_boundary) / (self.peak - self.left_boundary)
4041
elif self.peak < x < self.right_boundary:
4142
return (self.right_boundary - x) / (self.right_boundary - self.peak)
42-
raise ValueError(f"Invalid value {x} for fuzzy set {self}")
43+
44+
# Assign the message to a variable before raising the exception
45+
msg = f"Invalid value {x} for fuzzy set {self}"
46+
raise ValueError(msg)
4347

4448
def union(self, other: FuzzySet) -> FuzzySet:
4549
return FuzzySet(

0 commit comments

Comments
 (0)