コード例 #1
0
ファイル: test_numvalue.py プロジェクト: zypher22/pyomo
 def test_error1(self):
     class A(object): pass
     val = A()
     try:
         polynomial_degree(val)
         self.fail("Expected TypeError")
     except TypeError:
         pass
コード例 #2
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_unknownNumericType(self):
     ref = MyBogusNumericType(42)
     val = polynomial_degree(ref)
     self.assertEqual(val, 0)
     #self.assertEqual(val().val, 42)
     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
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_var1(self):
     m = ConcreteModel()
     m.x = Var()
     self.assertTrue(1, polynomial_degree(m.x))
コード例 #4
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_param2(self):
     m = ConcreteModel()
     m.p = Param(mutable=True)
     self.assertEqual(0, polynomial_degree(m.p))
コード例 #5
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_const4(self):
     val = NumericConstant(inf)
     self.assertEqual(0, polynomial_degree(val))
コード例 #6
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_inf(self):
     val = inf
     self.assertEqual(0, polynomial_degree(val))
コード例 #7
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_nan(self):
     val = nan
     self.assertEqual(0, polynomial_degree(val))
コード例 #8
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_long(self):
     val = int(1e10)
     self.assertEqual(0, polynomial_degree(val))
コード例 #9
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_float(self):
     val = 1.1
     self.assertEqual(0, polynomial_degree(val))
コード例 #10
0
ファイル: test_numvalue.py プロジェクト: Utkarsh-Detha/pyomo
 def test_bool(self):
     val = False
     self.assertEqual(0, polynomial_degree(val))