Skip to content

Commit

Permalink
Added new check in check_ind() to ensure that all individuals have a …
Browse files Browse the repository at this point in the history
…genome.
  • Loading branch information
mikefenton committed Jul 13, 2017
1 parent 4bb9836 commit f082308
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/utilities/representation/check_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ def check_ind(ind, check):
:return: False if everything is ok, True if there is an issue.
"""

if ind.genome == []:
# Ensure all individuals at least have a genome.
return True

if ind.invalid and \
((check == "crossover" and params['NO_CROSSOVER_INVALIDS']) or
(check == "mutation" and params['NO_MUTATION_INVALIDS'])):
Expand Down Expand Up @@ -389,14 +393,23 @@ def check_tree(tree):
"""

if tree.children:


if not tree.codon:
s = "utilities.representation.check_methods.check_tree\n" \
"Error: Node with children has no associated codon."
raise Exception(s)

for child in tree.children:

if child.parent != tree:
s = "utilities.representation.check_methods.check_tree\n" \
"Error: Child doesn't belong to parent.\n" \
" Child parent: %s\n" \
" Actual parent: %s" % (child.parent.root, tree.root)
" Actual parent: %s\n" \
" Child P depth: %s\n" \
" Parent depth: %s" % \
(child.parent.root, tree.root,
child.parent.depth, tree.depth)
raise Exception(s)

else:
Expand Down

0 comments on commit f082308

Please sign in to comment.