summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: caa73f9)
raw | patch | inline | side by side (parent: caa73f9)
author | Alvin Penner <penner@vaxxine.com> | |
Mon, 19 Jul 2010 22:54:52 +0000 (18:54 -0400) | ||
committer | Alvin Penner <penner@vaxxine.com> | |
Mon, 19 Jul 2010 22:54:52 +0000 (18:54 -0400) |
share/extensions/funcplot.py | patch | blob | history |
index e5f93d4309eab1cd91f7b39fc60d83930853f69d..1264298532fd574fc81c57776e700803449a61ea 100644 (file)
@@ -70,10 +70,14 @@ def drawfunction(xstart, xend, ybottom, ytop, samples, width, height, left, bott
ytop = (bottom+height-yzero)/scaley
# functions specified by the user
- if fx != "":
- f = eval('lambda x: ' + fx.strip('"'))
- if fpx != "":
- fp = eval('lambda x: ' + fpx.strip('"'))
+ try:
+ if fx != "":
+ f = eval('lambda x: ' + fx.strip('"'))
+ if fpx != "":
+ fp = eval('lambda x: ' + fpx.strip('"'))
+ # handle incomplete/invalid function gracefully
+ except SyntaxError:
+ return []
# step is the distance between nodes on x
step = (xend - xstart) / (samples-1)