def test_error(self): class A(object): pass val = A() try: is_fixed(val) self.fail("Expected TypeError") except TypeError: pass
def test_unknownNumericType(self): ref = MyBogusNumericType(42) self.assertTrue(is_fixed(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)
def test_const1(self): val = NumericConstant(1.0) self.assertTrue(is_fixed(val))
def test_string(self): self.assertTrue(is_fixed('foo'))
def test_long(self): val = int(1e10) self.assertTrue(is_fixed(val))
def test_int(self): self.assertTrue(is_fixed(1))
def test_float(self): self.assertTrue(is_fixed(1.1))
def test_bool(self): self.assertTrue(is_fixed(True))
def test_none(self): self.assertTrue(is_fixed(None))