示例#1
0
    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)
示例#2
0
    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())
示例#3
0
    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())
示例#4
0
 def testHyperInitVal(self):
     v = fracttypes.Var(fracttypes.Hyper, [1.234, -7.89, 11.1, 1.0e10])
     self.checkQuadInitVal(v)
示例#5
0
 def testBoolInitVal(self):
     v = fracttypes.Var(fracttypes.Bool, 1)
     self.checkIntInitVal(v)
示例#6
0
 def testIntInitVal(self):
     v = fracttypes.Var(fracttypes.Int, 1)
     self.checkIntInitVal(v)
示例#7
0
    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())