I do not understand why i get this error: [...] got multiple values for argument [...]

I do not understand why i get this error: [...] got multiple values for argument [...]

我定义了以下函数:

def lattice_pipe(real_coords, guess_cmap): 
    guess_coords = laplacian_coords(guess_cmap)
    return fitness(real_coords, kabsch(real_coords,guess_coords))

我这样称呼它:

fit = list(map(functools.partial(lattice_pipe, real_coords = coords_real, guess_cmap = cmap_guess), population))

但是我收到以下错误:

fit = list(map(functools.partial(lattice_pipe, real_coords = coords_real, guess_cmap = cmap_guess), population))

TypeError: lattice_pipe() got multiple values for argument 'real_coords'

我不明白为什么我会得到这个,因为我认为我只给它提供了它需要的两个参数,即 real_coords 和 guess_cmap...

感谢您的帮助!

如果您想从 population 获取 guess_cmap,请不要在 functools.partial() 调用中绑定它。使用列表理解从每个元素中提取它。

fit = map(functools.partial(lattice_pipe, real_coords = coords_real), [p['guess_cmap'] for p in population])