<lambda>() takes 1 positional argument but 2 were given <lambda>() takes 1 positional argument but 2 were given numpy numpy

<lambda>() takes 1 positional argument but 2 were given


The algorithm of the answer that you indicate is not written in python, so which obviously can fail, considering the official docs I have implemented the following solution:

import numpy as npfrom scipy.optimize import minimizex0 = 10, 10, 10vectors = [    np.array([1, 2, 3]),    np.array([1, 0, 2]),    np.array([3, 2, 4]),    np.array([5, 2, -1]),    np.array([1, 1, -1]),]unit_vectors = [vector / np.linalg.norm(vector) for vector in vectors]constraints = [    {"type": "ineq", "fun": lambda x, u=u: (np.dot(x, u) - 1)} for u in unit_vectors]target = lambda x: np.linalg.norm(x)res = minimize(fun=target, x0=x0, constraints=constraints)print(res.x)

Output:

[1.38118173 0.77831221 0.42744313]