Beispiel #1
0
def test_valid_func1():
    m, n = 3, 50
    p = np.array([1, 2, 3])
    x = np.linspace(-5, 5, n)
    func = lambda p, x : p[0]*np.exp(-p[1]*x) + p[2]

    lm_func = _LMFunction(func, args=(x,))
    assert_(__py_verify_funcs(lm_func, p, m, n))
Beispiel #2
0
def test_valid_func1():
    m, n = 3, 50
    p = np.array([1, 2, 3])
    x = np.linspace(-5, 5, n)
    func = lambda p, x: p[0] * np.exp(-p[1] * x) + p[2]

    lm_func = _LMFunction(func, args=(x, ))
    assert_(__py_verify_funcs(lm_func, p, m, n))
Beispiel #3
0
def test_valid_method():
    m, n = 3, 50
    p = np.array([1, 2, 3])
    x = np.linspace(-5, 5, n)

    class Foo(object):
        def func(self, p, x):
            return p[0]*np.exp(-p[1]*x) + p[2]

    lm_func = _LMFunction(Foo().func, args=(x,))
    assert_(__py_verify_funcs(lm_func, p, m, n))
Beispiel #4
0
def test_valid_method():
    m, n = 3, 50
    p = np.array([1, 2, 3])
    x = np.linspace(-5, 5, n)

    class Foo(object):
        def func(self, p, x):
            return p[0] * np.exp(-p[1] * x) + p[2]

    lm_func = _LMFunction(Foo().func, args=(x, ))
    assert_(__py_verify_funcs(lm_func, p, m, n))
Beispiel #5
0
def test_valid_func2():
    m, n = 3, 50
    p = np.array([1, 2, 3])
    x = np.linspace(-5, 5, n)
    func = lambda p, x : p[0]*np.exp(-p[1]*x) + p[2]
    def jacf(p, x):
        y = np.empty((n,m))
        y[:,0] = np.exp(-p[1]*x)
        y[:,1] = -p[0] * x * np.exp(-p[1]*x)
        y[:,2] = np.ones(x.size)
        return y

    lm_func = _LMFunction(func, args=(x,),  jacf=jacf)
    assert_(__py_verify_funcs(lm_func, p, m, n))
Beispiel #6
0
def test_valid_func2():
    m, n = 3, 50
    p = np.array([1, 2, 3])
    x = np.linspace(-5, 5, n)
    func = lambda p, x: p[0] * np.exp(-p[1] * x) + p[2]

    def jacf(p, x):
        y = np.empty((n, m))
        y[:, 0] = np.exp(-p[1] * x)
        y[:, 1] = -p[0] * x * np.exp(-p[1] * x)
        y[:, 2] = np.ones(x.size)
        return y

    lm_func = _LMFunction(func, args=(x, ), jacf=jacf)
    assert_(__py_verify_funcs(lm_func, p, m, n))