Partially fix (improve?) calc_weights.py, specifically in its call to scipy.optimize.fmin_tnc