我定义了以下函数:
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))
但我收到以下错误:
适合 = 列表(地图(functools.partial(lattice_pipe,real_coords = coords_real,guess_cmap = cmap_guess),人口))
类型错误:lattice_pipe() 为参数“real_coords”获得了多个值
我不明白为什么我会得到这个,因为我认为我只给了它它需要的两个参数,即 real_coords 和 guess_cmap ...
感谢您的帮助!
如果你想得到guess_cmap
from population
,不要在functools.partial()
调用中绑定它。使用列表理解从每个元素中提取它。
fit = map(functools.partial(lattice_pipe, real_coords = coords_real), [p['guess_cmap'] for p in population])
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句