def test_basic(self):
        f = lambda p, x: p[0]*x + p[1]
        x = [1, 5, 3, 7]
        y = [2, 7, 6, 11]

        p, pext = fit(f, x, y, init_pars=[0, 0])
        assert_allclose(p, [1.4, 0.9])
        assert_allclose(pext, [[0.05, -0.20000002], [-0.20000002, 1.05000008]])

        ye = [0.00001, 1000000, 0.00001, 1000000]
        p, pext = fit(f, x, y, ye, init_pars=[0, 0])
        assert_allclose(p, [2.0, 0], atol=0.001)
    def test_error(self):
        f = lambda p, x: p[0]*x
        x = [1, 2, 3]
        y = [0.7, 1.3, 2.5]

        y_ext = [0.1, 0.1, 0.1]
        p, pext = fit(f, x, y, y_ext, init_pars=[-3])
        assert_allclose(p, [0.77142857])
        assert_array_almost_equal(pext, [[0.000714]])

        y_ext = [0.1, 0.2, 0.3]
        p, pext = fit(f, x, y, y_ext, init_pars=[-3])
        assert_allclose(p, [0.72777778])
        assert_array_almost_equal(pext, [[0.00333333]])
    def test_boot_again(self):
        f = lambda p, x: p[0]*x
        x = [1, 2, 3]
        y = [1, 2, 3]

        yb = [[2, -1], [4, -2], [6, -3]]
        p, pext = fit(f, x, y, yb, init_pars=[-3])
        assert_allclose(p, [1])
        assert_allclose(pext, [[2, -1]])

        yb = [[3, -1], [2, -2], [7, -3]]
        p, pext = fit(f, x, y, yb, init_pars=[-3])
        assert_allclose(p, [1])
        assert_allclose(pext, [[1.60869565, -1]])
    def test_superbasic(self):
        f = lambda p, x: p[0]*x + p[1]
        x = [1, 2, 3]
        y = [2, 3, 4]

        p, pext = fit(f, x, y, init_pars=[0, 0])
        assert_allclose(p, [1, 1])
    def test_boot(self):
        f = lambda p, x: p[0]*x + p[1]
        x = [1, 2, 3]
        y = [2, 3, 4]
        yb = [
            [2, 3, 7],
            [3, 6, 10],
            [4, 9, 13],
        ]

        p, pext = fit(f, x, y, yb, init_pars=[0, 0])
        assert_allclose(p, [1, 1])
        assert_allclose(
            pext,
            [[1, 3, 3],
             [1, 0, 4]],
            atol=1e-7
        )