I have just started to use the DEAP package in python. Following the tutorial, I can't understand this statement:
toolbox.register("cross",tools.cxTwoPoint)
I understand that tools.cxTwoPoint
is to call the cxTwoPoint
function. However, I checked the source code, the cxTwoPoint
function is not within tools
module, and it is a defined function within crossover.py
. Also, I didn't find any statement in tools.py
which may relate to crossover.py
or cxTwoPoint
.
Can someone help me? Many many thanks!!!
The tools.py
is used for benchmarking the algorithm. As we can seen from __init__.py
, there is a statement from .crossover import *
which means import all of the functions in the crossover
module where located same directory as __init__.py
. This gives you a easy way to access these functions in other files. And __init__.py
are required to make Python trent the directories as containing packages as answered in:What is __init__.py for?.