diff --git a/src/__pycache__/model.cpython-39.pyc b/src/__pycache__/model.cpython-39.pyc index 838b6bd..7f96f55 100644 Binary files a/src/__pycache__/model.cpython-39.pyc and b/src/__pycache__/model.cpython-39.pyc differ diff --git a/src/glimpse.py b/src/glimpse.py index 45714a3..ec2ce66 100644 --- a/src/glimpse.py +++ b/src/glimpse.py @@ -54,16 +54,16 @@ for i in lll: if (i.id == j.parent): i.add_child(j) -print('\n', "Liste des conditions (node_id, parent_id, nb d'enfants, +/- liste des enfants)", '\n') +print('\n', "conditions (node_id, parent_id, nb enfants, liste enfants)", '\n') -affichage = '' +dsp = '' for i in lll: - affichage = str(i.id) + ' ' + str(i.parent) + ' n=' + str(len(i.ch)) + ' ' + dsp = str(i.id) + ' ' + str(i.parent) + ' n=' + str(len(i.ch)) + ' ' if len(i.ch) > 0: for c in range(0, len(i.ch)): - affichage += str(i.ch[c].id) + ', ' - print(affichage) + dsp += str(i.ch[c].id) + ', ' + print(dsp) ## @@ -109,11 +109,11 @@ print() sp = model.testmodel.get_states().get_space(0) size = model.testmodel.get_parameters().spaceparam.get_dimension().get_x() -nb_sites = int(model.testmodel.get_parameters().spaceparam.get_site_multiplicity()) +sites = int(model.testmodel.get_parameters().spaceparam.get_site_multiplicity()) nb_arrows = int(model.testmodel.get_states().get_space(0).get_nb_arrows()) -print("space size = ", size, " nb de sites par cellule = ", nb_sites, +print("space size = ", size, " nb de sites par cellule = ", sites, " nb total de flèches dans l'espace = ", nb_arrows) print(' | ', end=' ') @@ -129,22 +129,24 @@ print(' | ', end=' ') for n in range(0, size + 1): - for s in range(0, nb_sites): + for s in range(0, sites): arr = 0 for a in range(0, nb_arrows): if (sp.get_arrow(a).get_coord("x") == n and sp.get_arrow(a).get_site() == s): arr = sp.get_arrow(a).get_weight() if arr > 0: - print(str(arr), end = ' ') + print(str(arr), end=' ') else: - print('.', end = ' ') + print('.', end=' ') - print(' | ', end = ' ') + print(' | ', end=' ') -print('\n ' + ' ' * nb_sites * 2, end = '') +print('\n ' + ' ' * sites * 2, end='') for k in range(0, size + 1): - if k < 9: print(k + 1, end=' '+ ' ' * nb_sites * 2) - else: print(k + 1, end=' '+ ' ' * nb_sites * 2) + if k < 9: + print(k + 1, end=' ' + ' ' * sites * 2) + else: + print(k + 1, end=' ' + ' ' * sites * 2) diff --git a/src/model.py b/src/model.py index c1989e1..289f39c 100644 --- a/src/model.py +++ b/src/model.py @@ -144,7 +144,7 @@ class Spaceparam: return self.__dimension def set_dimension(self, value): - self.__dimension = str(value) # TODO Assert + self.__dimension = str(value) # TODO Assert class Axis: @@ -155,13 +155,14 @@ class Axis: return self.node.attrib["name"] def set_name(self, value): - pass # TODO (The user can create a complete model from scratch.) + pass # TODO (The user can create a complete model from scratch.) def get_size(self): return int(self.node.attrib["size"]) def set_size(self, value): - pass # TODO (The user can create a complete model from scratch.) + pass # TODO (The user can create a complete model from scratch.) + class Dimension: __axis = [] @@ -173,7 +174,7 @@ class Dimension: return int(self.node.get("x")) def set_x(self, value): - self.node.attrib["x"] = value # TODO Assert + self.node.attrib["x"] = value # TODO Assert def get_y(self): return int(self.node.get("y")) @@ -183,6 +184,7 @@ class Dimension: # TODO z, u, v, w,... + class Parameters: def __init__(self, node): @@ -228,7 +230,7 @@ class Object: return self.__arrows[i] def set_arrow(self, i, value): - self.__arrows[i] = value # TODO Assert + self.__arrows[i] = value # TODO Assert class Objects: @@ -244,7 +246,7 @@ class Objects: return self.__objects[i] def set_object(self, i, Object): - self.__objects[i] = Object # TODO Assert + self.__objects[i] = Object # TODO Assert ## States @@ -289,25 +291,27 @@ class TreeNode(object): self.parent = parent self.ch = [] self.x = x -# TODO self.y = y,... + # TODO self.y = y,... self.site = site self.weight = weight - def id(self): return id + def id(self): + return id - def add_child(self,ch_id): + def add_child(self, ch_id): self.ch.append(ch_id) self.ch = sorted(self.ch, key=id) ## Conditions + class Condition: def __init__(self, node): self.node = node def get_coord(self, axis): -# print(self.node.get(axis)) - return int(self.node.get(axis)) + # print(self.node.get(axis)) + return int(self. node.get(axis)) def set_coord(self, axis, value): self.node.attrib[axis] = str(value) @@ -352,6 +356,7 @@ class Conditions: def get_conditions_array(self): return self.__conditions + class Transition: __arrows = [] @@ -406,6 +411,7 @@ class Arrow: def set_weight(self, weight): self.node.attrib["weight"] = str(weight) + class Model: def __init__(self, modelpath, schemapath): @@ -468,6 +474,4 @@ testmodel = Model(modelPath, schemaPath) # print(testmodel.get_conditions().get_condition(0).get_weight()) - - # TODO weight_max