1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 """This set represents a non-fuzzy number."""
20
21 __revision__ = "$Id: Singleton.py,v 1.18 2010-10-29 19:24:41 rliebscher Exp $"
22
23
24 from fuzzy.set.Polygon import Polygon
25 from fuzzy.utils import prop
26 from fuzzy.Exception import FuzzyException
31 """This set represents a non-fuzzy number.
32
33 Its membership is only for x equal 1.::
34
35 *
36 |
37 |
38 |
39 -----+-----
40 x
41
42 See also U{http://pyfuzzy.sourceforge.net/demo/set/Singleton.png}
43 """
44
49
50
51 @prop
53 """x
54 @type: float"""
55 def fget(self):
56 return self._x
57 def fset(self, value):
58 self._x = float(value)
59 self._update()
60 return locals()
61
69
71 """Get membership of value x."""
72 if x == self._x:
73 return 1.0
74 else:
75 return 0.0
76
78 """Return center of gravity."""
79 return self._x
80
82 """Don't let anyone destroy our singleton."""
83 raise FuzzyException()
84
86 """Don't let anyone destroy our singleton."""
87 raise FuzzyException()
88
90 """Don't let anyone destroy our singleton."""
91 raise FuzzyException()
92
94 """Return representation of instance.
95
96 @return: representation of instance
97 @rtype: string
98 """
99 return "%s.%s(x=%s)" % (self.__class__.__module__, self.__class__.__name__, self._x)
100