예제 #1
0
def test_plot_ccf():
    lags, correlation_coeffs, confidence = ccf([1, 2, 3], [4, 5, 6])
    n_figs = plt.gcf().number
    ax = plot_ccf(lags, correlation_coeffs, confidence)

    assert isinstance(ax, matplotlib.axes.Axes)
    assert n_figs + 1 == plt.gcf().number
예제 #2
0
def test_ccf():
    lags, correlation_coeffs, confidence = ccf([1, 2, 3], [4, 5, 6])
    np.testing.assert_array_equal(lags, np.array([0, 1, 2]))
    np.testing.assert_array_equal(correlation_coeffs,
                                  np.array([1.0, 0.0, -0.5]))
    np.testing.assert_allclose(confidence,
                               np.array([1.13158573, 1.13158573, 1.13158573]))
예제 #3
0
def test_ccf_raises():
    with pytest.raises(ValueError):
        ccf([1, 2, 3], [])

    with pytest.raises(ValueError):
        ccf([1, 2, 3], [4, 5, 6], n_lags=-2)

    with pytest.raises(ValueError):
        ccf([1, 2, 3], [4, 5, 6], n_lags=20)
예제 #4
0
def test_check_ccf():
    lags, correlation_coeffs, confidence = ccf([1, 2, 3], [4, 5, 6])
    assert check_ccf(lags, correlation_coeffs, confidence)[0]