From: Tim Vieira Date: Wed, 10 Jul 2013 02:51:32 +0000 (-0400) Subject: fixed force-directed layout. X-Git-Url: https://hydra-www.ietfng.org/gitweb/?a=commitdiff_plain;h=fd3f52bc1215f275f281183be567452cc1a3e64e;p=dyna2 fixed force-directed layout. --- diff --git a/examples/force.dyna b/examples/force.dyna index 2872fa7..f1845bb 100644 --- a/examples/force.dyna +++ b/examples/force.dyna @@ -29,17 +29,17 @@ x(U,T) += a * forceX(U,T-1). y(U,T) += a * forceY(U,T-1). % make graph symmetric. -edge(A,B) := 1 for edge(B,A). +edge(A,B) := edge(B,A). % collect nodes. -node(U) := true for edge(U,_). -node(U) := true for edge(_,U). +node(U) :- true for _ is edge(U,_). +node(U) :- true for _ is edge(_,U). % pack x and y into a tuple pos(U,T) := tuple(x(U, T), y(U, T)). % visualization -frame(T, &text(Name, pos(Name, T))) := true for _ is node(Name). +frame(T, &text(Name, pos(Name, T))) := true for node(Name). frame(T, &line(pos(U, T), pos(V, T))) := true for _ is edge(U,V). % declare some edges diff --git a/src/Dyna/Backend/Python/interpreter.py b/src/Dyna/Backend/Python/interpreter.py index 7f65a2c..4a4c564 100644 --- a/src/Dyna/Backend/Python/interpreter.py +++ b/src/Dyna/Backend/Python/interpreter.py @@ -4,46 +4,12 @@ TODO ==== - - More info in crash handler. (stack trace, repl transcript, cmd-line args, - version control info, and dyna source is enough) - - dyna syntax which just gets passed to the backend: - - running repl commands, loaders, post-procesors - - - hook for python imports? or maybe an arbirary preamble/epilogue. - - :- python "from bar import foo, baz" - - - sheebang? - - - vbench: a script which tracks performace over time (= git commits). - - - profiler workflow - - kcachegrind - $ (PYTHONPATH=src/Dyna/Backend/Python/ pycachegrind src/Dyna/Backend/Python/interpreter.py examples/papa.dyna) - - cProfile + snakeviz - $ python -m cProfile -o prof src/Dyna/Backend/Python/interpreter.py examples/force.dyna >/dev/null && snakeviz prof - - - unit tests and code coverage. - - - doc tests for Dyna code. - - Use Dyna do some more work! think about using Dyna to maintain rules, update handlers, and indices (as Jason points out indices are just memoized queries). - - Subscriptions: - - TODO: users are automatically be subscribed to errors. - - everything - - functor - - ignore variable - - show diffs - - - TODO: True and 1 are equivalent. This sometimes leads to strange behavior. - FASTER ====== diff --git a/src/Dyna/Backend/Python/post/trace.py b/src/Dyna/Backend/Python/post/trace.py index 5e8504f..ed72d2f 100644 --- a/src/Dyna/Backend/Python/post/trace.py +++ b/src/Dyna/Backend/Python/post/trace.py @@ -178,8 +178,8 @@ class Crux(object): fn_args = [self.get_function(y) for y in x.body] # infix - if (not label.isalpha() and not label.startswith('&') and len(fn_args) == 2) \ - or label in ('in', 'and', 'or'): + if (not label[0].isalpha() and label[0] not in ('$','&') and len(fn_args) == 2) \ + or label in ('in', 'and', 'or', 'with_key', '->', 'is'): [a,b] = fn_args return '(%s %s %s)' % (a, label, b) return '%s(%s)' % (label, ', '.join(fn_args)) diff --git a/test/repl/alist.dynadoc b/test/repl/alist.dynadoc index 832a246..1744450 100644 --- a/test/repl/alist.dynadoc +++ b/test/repl/alist.dynadoc @@ -37,4 +37,4 @@ No results. > query findall(3, set(3, "three", a)) -findall(3, set(3, "three", a)) = ["three", "c", "d"]. \ No newline at end of file +findall(3, set(3, "three", a)) = ["three", "c", "d"].