关于python的妙处在于,您可以定义返回其他函数的函数,请尝试currying:
def make_mix(numg): def mix(x, *p): ng = numg p1 = p[:3*ng] p2 = p[3*ng:] a = sumarray(gaussian(x,p1),lorentzian(x,p2)) return a return mix
接着
leastsq, covar = opt.curve_fit(make_mix(numg),energy,intensity,inputtot)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)