示例#1
0
 def parse__transform_(self, val, f):
     which_transform = int(val)
     params = fctutils.ParamBag()
     params.load(f)
     self.set_transform(params.dict["formulafile"], params.dict["function"],
                        which_transform)
     self.transforms[which_transform].load_param_bag(params)
示例#2
0
    def testSetParamBag(self):
        fs1 = formsettings.T(Test.g_comp, None, "cf0")
        fs1.set_formula("standard.ucl", "DirectOrbitTraps", g_grad)

        bag = fctutils.ParamBag()
        bag.load(
            io.StringIO("""formulafile=stdexp.cfrm
function=DirectOrbitTraps
@_transfer=ident
@trapmergemode=mergenormal
@_density=1.00000000000000000
@_offset=0.00000000000000000
@angle=0.00000000000000000
@aspect=1.00000000000000000
@diameter=1.00000000000000000
@solidcolor=0
@startcolor=(1.00000000000000000,1.00000000000000000,1.00000000000000000,0.00000000000000000)
@threshold=0.25000000000000000
@trapcenter=(0.00000000000000000,0.00000000000000000)
@trapcolor=8
@trapfreq=1.00000000000000000
@trapmergemodifier=0
@trapmergeopacity=0.20000000000000001
@trapmergeorder=0
@traporder=4.00000000000000000
@trapshape=23
[endsection]
"""))
        fs1.load_param_bag(bag)

        self.assertEqual(fs1.get_func_value("@trapmergemode"), "mergenormal")
        self.assertEqual(fs1.get_named_param_value("@trapshape"), 23)
示例#3
0
 def parse__outer_(self, val, f):
     params = fctutils.ParamBag()
     params.load(f)
     (file, func) = self.normalize_formulafile(params, 1,
                                               fc.FormulaTypes.COLORFUNC)
     self.set_outer(file, func)
     self.forms[1].load_param_bag(params)
示例#4
0
    def testRoundTripData(self):
        comp = fctutils.Compressor()
        comp.write("""hello=goodbye
multiline=[
hello
f**k
mimsy
]
parishioner=arse
""")
        comp.close()
        data = comp.getvalue()
        full_input = "fish=wiggle\n" + data
        in_f = io.StringIO(full_input)

        fct = fctutils.ParamBag()
        fct.load(in_f)

        self.assertEqual("goodbye", fct.dict["hello"])
        self.assertEqual("arse", fct.dict["parishioner"])
        self.assertEqual("wiggle", fct.dict["fish"])
        self.assertEqual("""hello
f**k
mimsy
""", fct.dict["multiline"])
示例#5
0
    def parse__function_(self, val, f):
        params = fctutils.ParamBag()
        params.load(f)
        (file, func) = self.normalize_formulafile(params, 0,
                                                  fc.FormulaTypes.FRACTAL)

        self.set_formula(file, func, 0)

        for (name, val) in list(params.dict.items()):
            if name == "formulafile" or name == "function" or name == "formula" or name == "":
                continue
            elif name == "a" or name == "b" or name == "c":
                # back-compat for older versions
                self.forms[0].set_named_param("@" + name, val)
            else:
                self.forms[0].set_named_item(name, val)