'Fitting a line to 2 points with error in Python

I am trying to just fit a line to 2 points that have errors on the y axis but I can't seem to get the uncertainty out of it. Here is my (very simple) code:

import numpy as np
from scipy.optimize import curve_fit

nu = np.array([0,1])
B = np.array([0.191989,0.19089])
err_B = np.array([5,50])*1e-5

def lin(x, a, b):
    return a-b*(x+1/2)

popt, pcov = curve_fit(lin, nu, B,sigma=err_B)
print(popt)
print(np.sqrt(np.diag(pcov)))

For the actual values I get what I expect, but for the errors I get inf. This is clearly wrong, as I can literally do error propagation and get the error on a and b by doing the calculations by hand. Can someone help me fix this issue and get the errors on the parameters? Thank you!



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source