1616class FuzzySet :
1717 """
1818 A class for representing and manipulating triangular fuzzy sets.
19+
1920 Attributes:
20- name: The name or label of the fuzzy set.
21- left_boundary: The left boundary of the fuzzy set.
22- peak: The peak (central) value of the fuzzy set.
23- right_boundary: The right boundary of the fuzzy set.
21+ * name: The name or label of the fuzzy set.
22+ * left_boundary: The left boundary of the fuzzy set.
23+ * peak: The peak (central) value of the fuzzy set.
24+ * right_boundary: The right boundary of the fuzzy set.
25+
2426 Methods:
25- membership(x ): Calculate the membership value of an input 'x' in the fuzzy set.
26- union(other): Calculate the union of this fuzzy set with another fuzzy set.
27- intersection(other): Calculate the intersection of this fuzzy set with another.
28- complement(): Calculate the complement (negation) of this fuzzy set.
29- plot(): Plot the membership function of the fuzzy set.
27+ * membership(`x` ): Calculate the membership value of an input `x` in the fuzzy set.
28+ * union(` other` ): Calculate the union of this fuzzy set with another fuzzy set.
29+ * intersection(` other` ): Calculate the intersection of this fuzzy set with another.
30+ * complement(): Calculate the complement (negation) of this fuzzy set.
31+ * plot(): Plot the membership function of the fuzzy set.
3032
3133 >>> sheru = FuzzySet("Sheru", 0.4, 1, 0.6)
3234 >>> sheru
@@ -38,24 +40,24 @@ class FuzzySet:
3840 >>> siya
3941 FuzzySet(name='Siya', left_boundary=0.5, peak=1, right_boundary=0.7)
4042
41- # Complement Operation
43+ >>> # Complement Operation
4244 >>> sheru.complement()
4345 FuzzySet(name='¬Sheru', left_boundary=0.4, peak=0.6, right_boundary=0)
4446 >>> siya.complement() # doctest: +NORMALIZE_WHITESPACE
4547 FuzzySet(name='¬Siya', left_boundary=0.30000000000000004, peak=0.5,
4648 right_boundary=0)
4749
48- # Intersection Operation
50+ >>> # Intersection Operation
4951 >>> siya.intersection(sheru)
5052 FuzzySet(name='Siya ∩ Sheru', left_boundary=0.5, peak=0.6, right_boundary=1.0)
5153
52- # Membership Operation
54+ >>> # Membership Operation
5355 >>> sheru.membership(0.5)
5456 0.16666666666666663
5557 >>> sheru.membership(0.6)
5658 0.0
5759
58- # Union Operations
60+ >>> # Union Operation
5961 >>> siya.union(sheru)
6062 FuzzySet(name='Siya U Sheru', left_boundary=0.4, peak=0.7, right_boundary=1.0)
6163 """
@@ -77,6 +79,7 @@ def __str__(self) -> str:
7779 def complement (self ) -> FuzzySet :
7880 """
7981 Calculate the complement (negation) of this fuzzy set.
82+
8083 Returns:
8184 FuzzySet: A new fuzzy set representing the complement.
8285
@@ -94,8 +97,9 @@ def intersection(self, other) -> FuzzySet:
9497 """
9598 Calculate the intersection of this fuzzy set
9699 with another fuzzy set.
100+
97101 Args:
98- other: Another fuzzy set to intersect with.
102+ ` other` : Another fuzzy set to intersect with.
99103 Returns:
100104 A new fuzzy set representing the intersection.
101105
@@ -111,9 +115,10 @@ def intersection(self, other) -> FuzzySet:
111115
112116 def membership (self , x : float ) -> float :
113117 """
114- Calculate the membership value of an input 'x' in the fuzzy set.
118+ Calculate the membership value of an input `x` in the fuzzy set.
119+
115120 Returns:
116- The membership value of 'x' in the fuzzy set.
121+ The membership value of `x` in the fuzzy set.
117122
118123 >>> a = FuzzySet("a", 0.1, 0.2, 0.3)
119124 >>> a.membership(0.09)
@@ -141,8 +146,9 @@ def membership(self, x: float) -> float:
141146 def union (self , other ) -> FuzzySet :
142147 """
143148 Calculate the union of this fuzzy set with another fuzzy set.
149+
144150 Args:
145- other (FuzzySet): Another fuzzy set to union with.
151+ ` other` (FuzzySet): Another fuzzy set to union with.
146152 Returns:
147153 FuzzySet: A new fuzzy set representing the union.
148154
0 commit comments