Skip to content

Commit

Permalink
fix default argument mutation
Browse files Browse the repository at this point in the history
Don't mutate inputParameters. Since they are a default argument, they exist only one time in memory. If they are mutated, subsequent calls will use the computed parameters from the current call, while expecting defaults.
  • Loading branch information
Latios96 committed May 27, 2024
1 parent d04c585 commit 1efff80
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions python/flip/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,10 +232,11 @@ std::tuple<py::array_t<float>, float, py::dict> evaluate(const py::array_t<float
}
}
delete flip;

py::dict returnParams = {};
updateInputParameters(parameters, returnParams);

updateInputParameters(parameters, inputParameters);

return std::make_tuple(flipNumpy, meanError, inputParameters);
return std::make_tuple(flipNumpy, meanError, returnParams);
}

// Create command line, based on the Python command line string, for the FLIP tool to parse.
Expand Down

0 comments on commit 1efff80

Please sign in to comment.