Changeset 2650


Ignore:
Timestamp:
Jun 8, 2010 2:39:58 PM (11 years ago)
Author:
khunter
Message:

Refactor NumericValue? init function

While researching where and how to implement SOS handling, do a
drive-by cleanup.

  • Use more standard kwargs instead of kwd
  • Replace kwarg parsing with more standard kwargs.pop handling
File:
1 edited

Legend:

Unmodified
Added
Removed
  • coopr.pyomo/trunk/coopr/pyomo/base/numvalue.py

    r2201 r2650  
    7373    __hash__ = None
    7474
    75     def __init__(self, **kwds):
    76         if 'name' in kwds:
    77             self.name=str(kwds['name'])
    78         else:
    79             self.name="unknown"
    80         if 'domain' in kwds:
    81             self.domain=kwds['domain']
    82         elif 'within' in kwds:
    83             self.domain=kwds['within']
    84         else:
    85             self.domain=None
    86         if 'value' in kwds:
    87             if pyutilib.math.is_nan(kwds['value']):
    88                 self.value=pyutilib.math.nan
    89             else:
    90                 self.set_value(kwds['value'])
    91         else:
    92             self.value=None
     75    def __init__(self, **kwargs):
     76        self.name   = str(kwargs.pop('name', 'unknown'))
     77        self.domain = kwargs.pop('domain', None )
     78        self.domain = kwargs.pop('within', self.domain )
     79        value       = kwargs.pop('value', None )
     80
     81        if ( value and pyutilib.math.is_nan(value) ):
     82            value = pyutilib.math.nan
     83
     84        self.set_value(value)
    9385        self.model=None
    94         #print "NUMVAL",self.name,self.domain,self.value
     86
    9587
    9688    def is_constant(self):
Note: See TracChangeset for help on using the changeset viewer.