Пример #1
0
def test_sigmoid():
    """Test sigmoidal fitting and generation
    """
    n_pts = 1000
    x = np.random.randn(n_pts)
    p0 = (0., 1., 0., 1.)
    y = ea.sigmoid(x, *p0)
    assert_true(np.all(np.logical_and(y <= 1, y >= 0)))
    p = ea.fit_sigmoid(x, y)
    assert_allclose(p, p0, atol=1e-4, rtol=1e-4)

    y += np.random.rand(n_pts) * 0.01
    p = ea.fit_sigmoid(x, y)
    assert_allclose(p, p0, atol=0.1, rtol=0.1)
Пример #2
0
def test_sigmoid():
    """Test sigmoidal fitting and generation."""
    n_pts = 1000
    x = np.random.randn(n_pts)
    p0 = (0., 1., 0., 1.)
    y = ea.sigmoid(x, *p0)
    assert_true(np.all(np.logical_and(y <= 1, y >= 0)))
    p = ea.fit_sigmoid(x, y)
    assert_allclose(p, p0, atol=1e-4, rtol=1e-4)
    p = ea.fit_sigmoid(x, y, (0, 1, None, None), ('upper', 'lower'))
    assert_allclose(p, p0, atol=1e-4, rtol=1e-4)

    y += np.random.rand(n_pts) * 0.01
    p = ea.fit_sigmoid(x, y)
    assert_allclose(p, p0, atol=0.1, rtol=0.1)
Пример #3
0
def test_sigmoid():
    """Test sigmoidal fitting and generation."""
    n_pts = 1000
    x = np.random.RandomState(0).randn(n_pts)
    p0 = (0., 1., 0., 1.)
    y = ea.sigmoid(x, *p0)
    assert np.all(np.logical_and(y <= 1, y >= 0))
    p = ea.fit_sigmoid(x, y)
    assert_allclose(p, p0, atol=1e-4, rtol=1e-4)
    with pytest.warns(None):  # scipy convergence
        p = ea.fit_sigmoid(x, y, (0, 1, None, None), ('upper', 'lower'))
    assert_allclose(p, p0, atol=1e-4, rtol=1e-4)

    y += np.random.rand(n_pts) * 0.01
    p = ea.fit_sigmoid(x, y)
    assert_allclose(p, p0, atol=0.1, rtol=0.1)
Пример #4
0
def test_sigmoid():
    """Test sigmoidal fitting and generation."""
    n_pts = 1000
    x = np.random.RandomState(0).randn(n_pts)
    p0 = (0., 1., 0., 1.)
    y = ea.sigmoid(x, *p0)
    assert np.all(np.logical_and(y <= 1, y >= 0))
    p = ea.fit_sigmoid(x, y)
    assert_allclose(p, p0, atol=1e-4, rtol=1e-4)
    with pytest.warns(None):  # scipy convergence
        p = ea.fit_sigmoid(x, y, (0, 1, None, None), ('upper', 'lower'))
    assert_allclose(p, p0, atol=1e-4, rtol=1e-4)

    y += np.random.rand(n_pts) * 0.01
    p = ea.fit_sigmoid(x, y)
    assert_allclose(p, p0, atol=0.1, rtol=0.1)