Cleaned up repr using enumerate
This commit is contained in:
@ -179,8 +179,7 @@ class Population:
|
|||||||
|
|
||||||
|
|
||||||
def index_of(self, searched_chromosome):
|
def index_of(self, searched_chromosome):
|
||||||
"""Returns the index of the chromosome in the current population.
|
"""Returns the index of the chromosome in the current population."""
|
||||||
Returns -1 if no index found."""
|
|
||||||
|
|
||||||
return self.chromosome_list.index(searched_chromosome)
|
return self.chromosome_list.index(searched_chromosome)
|
||||||
|
|
||||||
@ -189,7 +188,7 @@ class Population:
|
|||||||
"""Returns a backend string representation of the entire population"""
|
"""Returns a backend string representation of the entire population"""
|
||||||
|
|
||||||
return ''.join(
|
return ''.join(
|
||||||
f'Chromosome - {index} {self[index]} ' +
|
f'Chromosome - {index} {chromosome} ' +
|
||||||
f'/ Fitness = {self[index].get_fitness()}\n'
|
f'/ Fitness = {chromosome.fitness}\n'
|
||||||
for index in range(len(self))
|
for index, chromosome in enumerate(self)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user