def testPartNames(self): v = fracttypes.Var(fracttypes.Float) self.assertEqual([""], v.part_names) v = fracttypes.Var(fracttypes.Complex) self.assertEqual(["_re", "_im"], v.part_names) v = fracttypes.Var(fracttypes.Color) self.assertEqual(["_re", "_i", "_j", "_k"], v.part_names)
def testComplexInitVal(self): v = fracttypes.Var(fracttypes.Complex, [1.234, -7.89]) self.assertEqual(["1.23399999999999999", "-7.88999999999999968"], v.init_val()) v.param_slot = 3 self.assertEqual(["t__pfo->p[3].doubleval", "t__pfo->p[4].doubleval"], v.init_val())
def testFloatInitVal(self): float_type = fracttypes.typeObjectList[fracttypes.Float] v = fracttypes.Var(fracttypes.Float, 1.234) self.assertEqual(["1.23399999999999999"], float_type.init_val(v)) self.assertEqual(["1.23399999999999999"], v.init_val()) v.param_slot = 3 self.assertEqual(["t__pfo->p[3].doubleval"], float_type.init_val(v)) self.assertEqual(["t__pfo->p[3].doubleval"], v.init_val())
def testHyperInitVal(self): v = fracttypes.Var(fracttypes.Hyper, [1.234, -7.89, 11.1, 1.0e10]) self.checkQuadInitVal(v)
def testBoolInitVal(self): v = fracttypes.Var(fracttypes.Bool, 1) self.checkIntInitVal(v)
def testIntInitVal(self): v = fracttypes.Var(fracttypes.Int, 1) self.checkIntInitVal(v)
def testGradientInitVal(self): v = fracttypes.Var(fracttypes.Gradient, 0) self.assertRaises(fracttypes.TranslationError, v.init_val) v.param_slot = 3 self.assertEqual(["t__pfo->p[3].gradient"], v.init_val())