From 75c63e8e2485114fd594e6498b297192333f4324 Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sun, 9 Jan 2022 12:01:01 +0100 Subject: [PATCH] =?UTF-8?q?WIP:=20premi=C3=A8res=20explorations.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/dimers random walk.xml | 31 ++++++++++++++++++-- src/__pycache__/rules_tree.cpython-39.pyc | Bin 0 -> 2071 bytes src/rules_tree.py | 25 ++++++++++------ src/show_tree.py | 34 ++++++++++++++++++++++ 4 files changed, 78 insertions(+), 12 deletions(-) create mode 100644 src/__pycache__/rules_tree.cpython-39.pyc create mode 100644 src/show_tree.py diff --git a/models/dimers random walk.xml b/models/dimers random walk.xml index 52f349f..4ee0e00 100644 --- a/models/dimers random walk.xml +++ b/models/dimers random walk.xml @@ -92,17 +92,22 @@ the neighbouring space unhit to East of the dimer is empty and the dimer identified by conditions (1,2) can be moved to East. --> - + + + + + + + parent="7" probability="1"> @@ -112,7 +117,27 @@ + parent="8" probability="1"> + + + + + + + + + + + + + + + + + + diff --git a/src/__pycache__/rules_tree.cpython-39.pyc b/src/__pycache__/rules_tree.cpython-39.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bf2a5fcc4af8618f489331804d6b535be57c55f5 GIT binary patch literal 2071 zcmbVMTW=dh6rS0ecO74HX%cd2+BBt-C0g@T`hZYHky0cG5~+9?32hh8NwUs*?aXeV ziTviEzV;{BkNy+<0)D}~^28tD0ilX>W^KntyuesNRYN;Ntb1uk8h2A5DCbw(zwBK3Z{MXSj>DcZPS-wna8C zeuWZ7_c7j}|3_jE>acfiL%qEPd+mGY)^qlbD-Y_!`>;nh-ti0X;yqXp3^?9+D)wQ& z{Q$pt20qFU!~r}+&AkDKgZ9?Bg(olJ0B`S4Zofne&!jJd8zw%K)-h|8f5$ekhNXj} zu7t1SH*u){QUhqH)4`%N!At$`pAcN-$Lq0hScrbNWH#;wA6Qz z`jQ>9F+XYq+RZL|pp=7Vv>%3X8s}lCtyt=y7b!^d5LvHaHGiX>EY3lDKS6wYmNz_< zAvsZmPZbbZB2pnzMKb0(2*XwqWmy=G*`J>@&$=CGwjoNJhtPR^sG{Ck^Ax#L;vTn> z7+p3q)oQBC1hO#40zBzmsS+9^(^(A(<2CNhe%I^sm3lJGp=HsRlSMr37q~NeYNkl| za*mmDQ5~tljhkPXrFD|2`I5AnOb>n4HwH72v7|z8|r)Ve;(=rM=qu%+v5*SSj zg@r{Zq4i&|SAC_TG@F5MYJ$uVKi$UUKfp(@vkmMVQ)72l2wR>y3q2|6lvn8X8p8%ehJ$pVW-|xTihdS@gEhWVNwq z;I>ti@)lW{w8|@rK!9%HURXHb3z*Wk`4pfHt{v6w=5z7Q3Zwl~$jwXn4zCoEa&;H^ z#v@UR(kpsIia@HUbHYXRL1NHi;?Q;mxu~^p-o$y_O|y{XdQKR)Rj6IOt6fx{g0>S# zMUX?58(X4A5!@OOC6c2g(L65rZVEb>eIS1jKX(f~-*>1ZxkQN9&~M~CRc+@DUdc7ZYK?OfU+y>?x~mL?FL%;#U6*jcVj zRsX#QpB8WWGpcj;Ig(}WmzL|x6`E9zwaZaPj<)xg ', node.children[0].id, end='\n') + print('] --> ', node.children[0].id, end='\n') + +""" +## get the tree + + +def get_tree(): + return root -print('\nNext step: single rule extraction from tree. 😃️') # print([node.id for node in LevelOrderIter(root) if node.is_leaf]) diff --git a/src/show_tree.py b/src/show_tree.py new file mode 100644 index 0000000..3a0bc19 --- /dev/null +++ b/src/show_tree.py @@ -0,0 +1,34 @@ +# from ete2 import Tree +from anytree import RenderTree +import rules_tree + +tree = rules_tree.get_tree() + +print('type: ', type(tree)) +print(tree.depth, ' < depth') +print(tree.is_leaf, ' < is_leaf') +print(tree.is_root, ' < is_root') +print(tree.height, ' < height') +print(tree.parent, ' < parent') +print(tree.ancestors, ' < ancestors') +print(tree.anchestors, ' < anchestors') +print(tree.siblings, ' < siblings') +print(len(tree.leaves), ' < len(tree.leaves)') +print(len(tree.path), ' < len(tree.path)') +print('path: ', tree.path) +print('children: ', tree.children) +print('descendants[0]: ', tree.descendants[0]) + +print('\n to fix: (leaves)', end='\n\n') +for pre, fill, node in RenderTree(tree): + treestr = u"%s%s" % (pre, node.id) + if type(node) == rules_tree.CondTreeNode: + print(treestr.ljust(19), node.weight, ' arrow(s) at [site', node.site, + 'in cell', node.x, end='') + if not node.depth == 2: # tree.depth() + print(end=']\n') + else: + print('] --> ', node.children[0].id, end='\n') + + +print('\nNext step: single rule extraction from tree. 😃️')