code: def optimize(self, angles0, target):
          
          def new_objective(angles):
              return self.f(angles, target)
  
          return scipy.optimize.minimize(
              new_objective,
              angles0,
              **self.optimizer_opt).x
docs: Calculate an optimum argument of an objective function.