Skip to content
Snippets Groups Projects
Commit 81e05cca authored by mehtank's avatar mehtank
Browse files

Add math utils to Function

parent af7dbaf2
No related merge requests found
......@@ -20,7 +20,8 @@ class Function:
self.fnstring = repr(obj)
def eval(self, parameterizable):
function = eval("lambda x : " + self.fnstring)
import svggen.utils.mymath as np
function = eval("lambda x : " + self.fnstring, locals())
if isinstance(self.params, (list, tuple)):
output = function(map(lambda x : parameterizable.getParameter(x, strict=False), self.params))
elif self.params:
......
......@@ -357,8 +357,9 @@ class Component(Parameterized):
for (parameterName, obj) in self.subcomponents[subComponent]["parameters"].iteritems():
try:
x = YamlFunction(obj).eval(self)
except:
except Exception as e:
print "Error trying to evaluate", obj
print e
raise
if x is not None:
self.setSubParameter(subComponent, parameterName, x)
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment