Changeset 682 for mds-and-trees


Ignore:
Timestamp:
09/02/17 14:12:51 (7 years ago)
Author:
konrad
Message:

Broken last lines in input logs will not crash the script anymore (the last, faulty entry will be ignored)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • mds-and-trees/tree-genealogy.py

    r681 r682  
    390390        x1_dist = 0
    391391        x2_dist = 0
    392         miny = y-20
    393         maxy = y+20
     392        miny = y-2000
     393        maxy = y+2000
    394394        i_left = bisect.bisect_left(self.y_sorted, miny)
    395395        i_right = bisect.bisect_right(self.y_sorted, maxy)
     
    524524        visited[0] = 1
    525525        self.props["depth"][0] = 0
    526 
    527526        while True:
    528527            current_node = nodes_to_visit[0]
     528
    529529            for child in self.tree.children[current_node]:
    530530                if visited[child] == 0:
     
    657657                    line_arr = line_arr[1].split(' ', 1)
    658658                if line_arr[0] == "[OFFSPRING]":
    659                     creature = json.loads(line_arr[1])
     659                    try:
     660                        creature = json.loads(line_arr[1])
     661                    except ValueError:
     662                        print("Json format error - the line cannot be read. Breaking the loading loop.")
     663                        # fixing arrays by removing the last element
     664                        # ! assuming that only the last line is broken !
     665                        self.parents.pop()
     666                        self.children.pop()
     667                        self.time.pop()
     668                        self.kind.pop()
     669                        self.life_lenght.pop()
     670                        nodes -= 1
     671                        break
     672
    660673                    if "FromIDs" in creature:
    661674
     
    769782    tree.load(dir, max_nodes=args.max_nodes)
    770783
     784
    771785    designer = Designer(tree, jitter=JITTER, time=TIME, balance=BALANCE)
    772786    designer.calculate_measures()
Note: See TracChangeset for help on using the changeset viewer.