Exemplo n.º 1
0
 def alignment_from_alignment_file(self, path):
     self.hitting_tiles = []
     with open(path) as f:
         astats = stats.AlignmentStats().from_file(f)
     for tile_key, scaling, tile_width, rotation, rc_offset, _ in astats:
         self.set_tile_alignment(tile_key, scaling, tile_width, rotation,
                                 rc_offset)
Exemplo n.º 2
0
def load_existing_score(stats_file_path):
    if os.path.isfile(stats_file_path):
        with open(stats_file_path) as f:
            try:
                return stats.AlignmentStats().from_file(f).score
            except (TypeError, ValueError):
                return 0
    return 0
Exemplo n.º 3
0
 def alignment_stats(self):
     hits = {'exclusive': len(self.exclusive_hits),
             'good_mutual': len(self.good_mutual_hits),
             'bad_mutual': len(self.bad_mutual_hits),
             'non_mutual': len(self.non_mutual_hits)}
     offsets = [tuple(map(float, tile.offset)) for tile in self.hitting_tiles]
     return stats.AlignmentStats().from_data([str(tile.key) for tile in self.hitting_tiles],
                                             [float(tile.scale) for tile in self.hitting_tiles],
                                             [float(tile.width) for tile in self.hitting_tiles],
                                             [float(tile.rotation_degrees) for tile in self.hitting_tiles],
                                             offsets,
                                             hits)