From ae6981a62480a0707227f0b11dedf007897dce2f Mon Sep 17 00:00:00 2001 From: Jean Sirmai Date: Sun, 9 Jan 2022 12:45:42 +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 | 4 +-- src/__pycache__/rules_tree.cpython-39.pyc | Bin 2071 -> 1659 bytes src/rules_tree.py | 40 +++++++++------------- src/show_tree.py | 14 +++----- 4 files changed, 23 insertions(+), 35 deletions(-) diff --git a/models/dimers random walk.xml b/models/dimers random walk.xml index 4ee0e00..7f5db43 100644 --- a/models/dimers random walk.xml +++ b/models/dimers random walk.xml @@ -126,7 +126,7 @@ - @@ -136,7 +136,7 @@ - diff --git a/src/__pycache__/rules_tree.cpython-39.pyc b/src/__pycache__/rules_tree.cpython-39.pyc index bf2a5fcc4af8618f489331804d6b535be57c55f5..a2075b53a2df516a215b26a383a528d1f0862c47 100644 GIT binary patch delta 882 zcmY*XO>fgc5Z&20w&NtOleQ+LO&db_hzh6@BB!cUQ1w_vD(b-qMWH)tn?TdpLC~ns zgZTjSx`^-@j)C6~Q%m{`CraIX$7qKuOF&})s#vW}s=6`kq%?KO| z6|}-a#0ZNCP9`{&;Iv3bAh_VZ=Gdr)7toFX7}}kZU|sGu(RTFyadXV@;yJ^{si9;? zhGo>KjDqEGhAhhAY{aC&X!@Eg-~WOtJ$8w-a=+?S(8NkNg=VLOmCjt3ud+AbDrkoD zSczZ@DD5l#-^fw-fg}y5iq*~~y3|08@|sh_%f!t2fVEDk%jsktYb38qLsGBPY6w+m zubHzT_$I6C!AIC#&>y&n8$E&BI<@=Xka6mCdG~^4erNhfJz}lQkw$0;w#h!gMm-x0 z`K^-r9QSs12eIPq4KRimF&xG)r23!vyyluz#+?Yh^JXPap;sheV1jyX4hzBk)XI7t zT=`$rxogqpWDnXd?hjh~^gefzm=R1-6zBK6R$KHA1}IvO4@*ROoPhD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X4A5!@OOC6c2g(L65rZVEb>eIS1jKX(f~-*>1ZxkQN9&~M~CRc+@DUdc7ZYK?OfU+y>?x~mL?FL%;#U6*jcVj zRsX#QpB8WWGpcj;Ig(}WmzL|x6`E9zwaZaPj<)xg pas de doublons # 2) tout node doit avoir un node_parent_id +# Process +# 1) lors de l'adoption, le parent doit exister -class CondTreeNode(NodeMixin): - def __init__(self, id, parent_id, x, site, weight): - super(CondTreeNode, self).__init__() +class TreeNode(NodeMixin): + def __init__(self, id, parent_id, weight, site, x, y, z): + super(TreeNode, self).__init__() self.id = id self.parent_id = parent_id self.parent = None - self.x = x # TODO self.y = y,z... - self.site = site self.weight = weight + self.site = site + self.x = x + self.y = y + self.z = z def is_adopted_by(self, parent_node): # print('orphan node ', self.id, ' is adopted by node ', parent_node.id) self.parent = parent_node -class TransTreeNode(NodeMixin): - def __init__(self, id, parent_id): - super(TransTreeNode, self).__init__() - self.parent_id = parent_id - self.parent = None - self.id = id - - def is_adopted_by(self, parent_node): - # print('orphan transition is adopted by leaf node', parent_node.id) - self.parent = parent_node - - conditions_set = set() transitions_set = set() root = None for i in range(0, len(model.testmodel.get_conditions().get_all())): condition = model.testmodel.get_conditions().get_one(i) - tmp = CondTreeNode(condition.get_self_id(), + tmp = TreeNode(condition.get_self_id(), condition.get_parent_id(), - condition.get_coord("x"), + condition.get_weight(), condition.get_site(), - condition.get_weight()) + condition.get_coord("x"), + None, None) conditions_set.add(tmp) if tmp.parent_id == 0: root = tmp for i in range(0, len(model.testmodel.get_transitions().get_all())): transition = model.testmodel.get_transitions().get_one(i) - transitions_set.add(TransTreeNode( + transitions_set.add(TreeNode( transition.get_id(), - transition.get_parent())) + transition.get_parent(), + None, None, None, None, None)) for i in conditions_set: for j in conditions_set: @@ -71,7 +65,7 @@ for condition_node in LevelOrderIter(root): for pre, fill, node in RenderTree(root): treestr = u"%s%s" % (pre, node.id) - if type(node) == CondTreeNode: + if type(node) == TreeNode: print(treestr.ljust(19), node.weight, ' arrow(s) at [site', node.site, 'in cell', node.x, end='') if not node.depth == 2: # tree.depth() diff --git a/src/show_tree.py b/src/show_tree.py index 3a0bc19..adc14e1 100644 --- a/src/show_tree.py +++ b/src/show_tree.py @@ -19,16 +19,10 @@ 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(treestr.ljust(46)) - -print('\nNext step: single rule extraction from tree. 😃️') +print('\nNext step: single rule extraction from tree.', + ' 😃️\nand learn how to use the Newick format.') +# http://etetoolkit.org/docs/2.3/tutorial/tutorial_trees.html