コード例 #1
0
ファイル: test_numvalue.py プロジェクト: zypher22/pyomo
 def test_error(self):
     class A(object): pass
     val = A()
     try:
         is_constant(val)
         self.fail("Expected TypeError")
     except TypeError:
         pass
コード例 #2
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_unknownNumericType(self):
     ref = MyBogusNumericType(42)
     self.assertTrue(is_constant(ref))
     from pyomo.core.base.numvalue import native_numeric_types, native_types
     self.assertIn(MyBogusNumericType, native_numeric_types)
     self.assertIn(MyBogusNumericType, native_types)
     native_numeric_types.remove(MyBogusNumericType)
     native_types.remove(MyBogusNumericType)
コード例 #3
0
ファイル: var.py プロジェクト: Robbybp/IDAES-CLC
def wrap_var(obj):
    """
    Provides a Wrapper around the obj if it is not a constant value; otherwise,
    returns the constant value.
    """
    if pe.is_constant(obj):
        return pe.value(obj)
    else:
        return Wrapper(obj)
コード例 #4
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_const2(self):
     val = NumericConstant('foo')
     self.assertTrue(is_constant(val))
コード例 #5
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_const1(self):
     val = NumericConstant(1.0)
     self.assertTrue(is_constant(val))
コード例 #6
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_string(self):
     self.assertTrue(is_constant('foo'))
コード例 #7
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_long(self):
     val = int(1e10)
     self.assertTrue(is_constant(val))
コード例 #8
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_int(self):
     self.assertTrue(is_constant(1))
コード例 #9
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_float(self):
     self.assertTrue(is_constant(1.1))
コード例 #10
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_bool(self):
     self.assertTrue(is_constant(True))
コード例 #11
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_none(self):
     self.assertTrue(is_constant(None))