From e19576f89052003af3e9f88e8499c846c16bd704 Mon Sep 17 00:00:00 2001 From: SimpleArt <71458112+SimpleArt@users.noreply.github.com> Date: Fri, 1 Jan 2021 10:48:59 -0500 Subject: [PATCH] Specific exceptions raised. --- src/parent/Parent.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/parent/Parent.py b/src/parent/Parent.py index d01c92e..08cfb32 100644 --- a/src/parent/Parent.py +++ b/src/parent/Parent.py @@ -13,7 +13,7 @@ def _check_selection_probability(selection_method): if 0 <= ga.selection_probability <= 1: selection_method(ga) else: - raise Exception("Selection probability must be between 0 and 1 to select parents.") + raise ValueError("Selection probability must be between 0 and 1 to select parents.") return new_method @@ -29,7 +29,8 @@ def _check_positive_fitness(selection_method): if ga.get_chromosome_fitness(0) > 0 and ga.get_chromosome_fitness(-1) >= 0: selection_method(ga) else: - raise Exception("Converted fitness values can't have negative values or be all 0. Consider using rank selection or stochastic selection instead.") + raise ValueError("Converted fitness values can't have negative values or be all 0." + + " Consider using rank selection or stochastic selection instead.") return new_method