Skip to content

pymoo/setup-positional-termination

Rule setup-positional-termination
Pack pymoo
Severity error
Fix unsafe, with xpd check --fix --unsafe-fixes
Library versions pymoo 0.6 and later

setup takes the termination by keyword since pymoo 0.6.0, and a second positional argument raises or is read as verbose. Write termination=.

algorithm = NSGA2(pop_size=100)
algorithm.setup(problem, ("n_gen", 200), seed=1)
algorithm.setup(problem, termination=("n_gen", 200), seed=1)

The rule reports a termination given to setup as the second positional argument, on a name the file binds to a pymoo algorithm.

pymoo setup(problem, ("n_gen", 7))
0.5.0 and older the second parameter is the termination
0.6.0 to 0.6.1.5 TypeError
0.6.1.6 and later the second parameter is verbose, and NSGA2 printed a line for every generation and was still running after 30

xpd check --fix --unsafe-fixes applies the fixes of this rule. Check the result, because an unsafe fix can change what the code does.

The unsafe fix writes termination= before the second argument.

xpd prints this message with the issue. A name that starts with $ stands for code from your file.

setup takes the termination by keyword since pymoo 0.6.0. A second positional argument raises TypeError up to 0.6.1.5. Since 0.6.1.6 it is read as verbose, so the run prints every generation and stops by the default termination. A run asked for 7 generations was still going after 30. Write termination=$T.

Browse the other rules of the pymoo pack.