Package fuzzy :: Package complement :: Module Parametric
[hide private]
[frames] | no frames]

Source Code for Module fuzzy.complement.Parametric

 1  # -*- coding: utf-8 -*- 
 2  # 
 3  # Copyright (C) 2009  Rene Liebscher 
 4  # 
 5  # This program is free software; you can redistribute it and/or modify it under 
 6  # the terms of the GNU Lesser General Public License as published by the Free  
 7  # Software Foundation; either version 3 of the License, or (at your option) any 
 8  # later version. 
 9  # 
10  # This program is distributed in the hope that it will be useful, but WITHOUT  
11  # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 
12  # FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more 
13  # details. 
14  #  
15  # You should have received a copy of the GNU Lesser General Public License 
16  # along with this program; if not, see <http://www.gnu.org/licenses/>.  
17  # 
18  """Abstract base class for any parametric fuzzy complement""" 
19  __revision__ = "$Id: Parametric.py,v 1.9 2010-10-29 19:24:41 rliebscher Exp $" 
20   
21  from fuzzy.complement.Base import Base 
22  from fuzzy.utils import prop 
23 24 -class Parametric(Base):
25 """Abstract base class for any parametric fuzzy complement 26 27 @ivar p: parameter for complement 28 @type p: float 29 """ 30 _range = None 31
32 - def __init__(self, p, *args, **keywords):
33 """Initialize type and parameter 34 35 @param p: parameter for complement 36 @type p: float 37 """ 38 super(Parametric, self).__init__(*args, **keywords) 39 self.p = p
40 41 # pylint: disable=E0211,E0202 42 #ID:E0211 Parametric.p: Method has no argument 43 #ID:E0202 Parametric.p: An attribute inherited from Parametric hide this method 44 @prop
45 - def p(): #@NoSelf
46 """x 47 @type: float""" 48 def fget(self): # pylint: disable=W0612,C0111 49 return self._p
50 def fset(self, value): # pylint: disable=W0612,C0111 51 self._checkParam(value) 52 self._p = value 53 return locals() 54 55 # pylint: disable=E0211 56 #ID:E0211 Parametric.p_range: Method has no argument 57 @prop
58 - def p_range(): #@NoSelf
59 """range(s) of valid values for p""" 60 def fget(self): # pylint: disable=W0612,C0111 61 return self._range 62 return locals() 63
64 - def _checkParam(self, value):
65 """check parameter if allowed for parameter p 66 @param value: the value to be checked 67 @type value: float""" 68 from fuzzy.utils import checkRange 69 if not checkRange(value, self._range): 70 from fuzzy.Exception import FuzzyException 71 raise FuzzyException("Parameter value %s is not allowed" % str(value))
72
73 - def __repr__(self):
74 """Return representation of instance. 75 76 @return: representation of instance 77 @rtype: string 78 """ 79 return "%s.%s(p=%s)" % (self.__class__.__module__, self.__class__.__name__, self._p)
80