From d4c9f3b926684595116c896d1059dee975600028 Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Fri, 20 Nov 2020 09:18:23 -0500 Subject: [PATCH] Exception comes after main code --- src/parent_selection/parent_selection_methods.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/parent_selection/parent_selection_methods.py b/src/parent_selection/parent_selection_methods.py index 41e0433..495e886 100644 --- a/src/parent_selection/parent_selection_methods.py +++ b/src/parent_selection/parent_selection_methods.py @@ -11,10 +11,10 @@ def check_selection_probability(selection_method): def check_positive_fitness(selection_method): def helper(ga): - if ga.get_chromosome_fitness(0) == 0 or ga.get_chromosome_fitness(-1) < 0: - raise Exception("Converted fitness values must be all positive. Consider using rank selection instead.") - else: + if ga.get_chromosome_fitness(0) > 0 and ga.get_chromosome_fitness(-1) >= 0: selection_method(ga) + else: + raise Exception("Converted fitness values must be all positive. Consider using rank selection instead.") return helper