我不明白为什么会出现这样的错误:[…]参数[…]有多个值

2024-06-29 01:04:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我定义了以下函数:

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

我这样称呼它:

^{pr2}$

但我得到了以下错误:

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'

我不明白为什么我会得到这个,因为我想我只给出了它需要的两个参数,一个是真坐标,另一个是猜想。。。在

谢谢你的帮助!在


Tags: 函数return定义def错误coordsrealcmap
1条回答
网友
1楼 · 发布于 2024-06-29 01:04:38

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

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

相关问题 更多 >