diff --git a/pybop/optimisers/base_optimiser.py b/pybop/optimisers/base_optimiser.py index ab3a30c2b..c5e475422 100644 --- a/pybop/optimisers/base_optimiser.py +++ b/pybop/optimisers/base_optimiser.py @@ -189,13 +189,9 @@ def _run(self): # Choose method to evaluate if self._needs_sensitivities: - - def f(x): - return self.cost.evaluateS1(x, minimising=self._minimising) + f = lambda x: self.cost.evaluateS1(x, minimising=self._minimising) else: - - def f(x, grad=None): - return self.cost(x, grad, minimising=self._minimising) + f = lambda x, grad=None: self.cost(x, grad, minimising=self._minimising) # Create evaluator object if self._parallel: