Ejemplo n.º 1
0
def __print_winning_ratios(text_file, winning_ratios, num_contiguous):
    for key in winning_ratios.keys():
        ratio = key.split(':')
        num_green_wins = ratio[0]
        num_purple_wins = ratio[1]
        message = "Green won " + num_green_wins + " districts "
        message += "and Purple won " + num_purple_wins + " districts "
        percent = winning_ratios[key] / num_contiguous * 100
        message += str(round(percent, 2)) + "% of the time."
        print_to_screen_and_file(message, text_file)
    print_to_screen_and_file("", text_file)  # Print extra newline character
Ejemplo n.º 2
0
 def __print_legend(self):
     print_to_screen_and_file('LEGEND', self.text_file)
     print_to_screen_and_file('  G - Green', self.text_file)
     print_to_screen_and_file('  P - Purple\n', self.text_file)
Ejemplo n.º 3
0
 def __print_bottom_border(self, border):
     print_to_screen_and_file('╚' + border + '╝\n', self.text_file)
Ejemplo n.º 4
0
 def __print_top_border(self, border):
     print_to_screen_and_file('╔' + border + '╗', self.text_file)
Ejemplo n.º 5
0
 def __print_district_and_party(self, district_map, i, j):
     district_and_party = self.__get_district_and_party_string(
         district_map, i, j)
     print_to_screen_and_file(' ' + district_and_party + ' ',
                              self.text_file,
                              end='')
Ejemplo n.º 6
0
 def __print_district_grid_column(self, district_grid, i):
     print_to_screen_and_file('║', self.text_file, end='')
     self.__print_district_grid_row(district_grid, i)
     print_to_screen_and_file('║', self.text_file)
Ejemplo n.º 7
0
 def __print_num_contiguous(self):
     num_contiguous = len(self.__contiguous_coordinate_list)
     message = 'We generated ' + str(
         num_contiguous) + ' contiguous random redistricting schemes.\n'
     print_to_screen_and_file(message, self.text_file)
Ejemplo n.º 8
0
def __print_percent_won(text_file, party, percentage_won):
    """Print the percentage of elections the party won."""
    message = party + " won " + str(round(percentage_won,
                                          2)) + "% percent of elections."
    print_to_screen_and_file(message, text_file)
Ejemplo n.º 9
0
def __print_statistics_report_header(text_file):
    """Print the header to the statistics report."""
    report_title = _REPORT_TITLE
    print_to_screen_and_file(report_title, text_file)
    border = get_border('-', len(report_title))
    print_to_screen_and_file(border, text_file)