From a65cdb1056374129f42b8943a5999aff179947e4 Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Fri, 20 Nov 2020 09:19:09 -0500 Subject: [PATCH] Consistent function decorator format --- src/survivor_selection/survivor_selection_methods.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/survivor_selection/survivor_selection_methods.py b/src/survivor_selection/survivor_selection_methods.py index 48d9128..fc5def3 100644 --- a/src/survivor_selection/survivor_selection_methods.py +++ b/src/survivor_selection/survivor_selection_methods.py @@ -1,13 +1,17 @@ import random +def append_to_next_population(survivor_method): + return lambda ga: ga.population.append_children(survivor_method(ga)) + + class Survivor_Selection: """Survivor selection determines which individuals should be brought to the next generation""" def __append_to_next_population(survivor_method): - return lambda ga: ga.population.append_children(survivor_method(ga)) + return append_to_next_population(survivor_method) - @__append_to_next_population + @append_to_next_population def fill_in_best(ga): """Fills in the next population with the best chromosomes from the last population""" @@ -15,7 +19,7 @@ class Survivor_Selection: return ga.population[:needed_amount] - @__append_to_next_population + @append_to_next_population def fill_in_random(ga): """Fills in the next population with random chromosomes from the last population""" @@ -23,7 +27,7 @@ class Survivor_Selection: return [random.choice(ga.population) for n in range(needed_amount)] - @__append_to_next_population + @append_to_next_population def fill_in_parents_then_random(ga): """Fills in the next population with all parents followed by random chromosomes from the last population"""