Skip to content

pymoo/setup-positional-termination

Pack Severity Fix Versions
pymoo error unsafe, with xpd check --fix --unsafe-fixes pymoo 0.6+

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

The second argument must be a tuple starting with a string or a get_termination call.

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.

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.

See all rules in the pymoo pack.