From 2ad19a50d3e8f35b061842b7624059d492dcb9b8 Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Fri, 20 Nov 2020 09:17:17 -0500 Subject: [PATCH] Cleaned up repr using enumerate --- src/structure/population.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/structure/population.py b/src/structure/population.py index 83bf086..5a52108 100644 --- a/src/structure/population.py +++ b/src/structure/population.py @@ -179,8 +179,7 @@ class Population: def index_of(self, searched_chromosome): - """Returns the index of the chromosome in the current population. - Returns -1 if no index found.""" + """Returns the index of the chromosome in the current population.""" return self.chromosome_list.index(searched_chromosome) @@ -189,7 +188,7 @@ class Population: """Returns a backend string representation of the entire population""" return ''.join( - f'Chromosome - {index} {self[index]} ' + - f'/ Fitness = {self[index].get_fitness()}\n' - for index in range(len(self)) + f'Chromosome - {index} {chromosome} ' + + f'/ Fitness = {chromosome.fitness}\n' + for index, chromosome in enumerate(self) )