PonyGE / PonyGE2

PonyGE2: grammatical evolution and variants in Python
GNU General Public License v3.0
155 stars 92 forks source link

Fix RecursionError #133

Closed LBannenberg closed 3 years ago

LBannenberg commented 3 years ago

Sometimes this condition causes a RecursionError.

It seems like sometimes mutation.py line 159 computes max_depth = params['MAX_TREE_DEPTH'] - new_tree.depth as 0, probably when trying to turn a max depth leaf into a new subtree.

Going by the comment this condition was only supposed to be true when no depth_limit was intended, not with a a 0 remaining depth_limit. Changing the condition to is None identity comparison does this more accurately and has resolved the error for me.

dvpfagan commented 3 years ago

Thanks again for the fix.