Пример #1
0
def test_move_mean_random(rand_array):
    array = rand_array[0]

    expected = pd.Series(array).rolling(window=10, min_periods=1).mean().values
    result = move_mean(array, 10, min_count=1)
    assert_almost_equal(expected, result)

    expected = pd.Series(array).rolling(window=3, min_periods=3).mean().values
    result = move_mean(array, 3, min_count=3)
    assert_almost_equal(expected, result)
Пример #2
0
def test_move_mean_random(rand_array):
    array = rand_array[0]

    expected = pd.Series(array).rolling(window=10, min_periods=1).mean().values
    result = move_mean(array, 10, min_count=1)
    assert_almost_equal(expected, result)

    expected = pd.Series(array).rolling(window=3, min_periods=3).mean().values
    result = move_mean(array, 3, min_count=3)
    assert_almost_equal(expected, result)
Пример #3
0
def test_move_mean():
    array = np.arange(100.0)
    array[::7] = np.nan

    expected = pd.Series(array).rolling(window=5, min_periods=1).mean().values
    result = move_mean(array, 5, min_count=1)
    assert_almost_equal(expected, result)
Пример #4
0
def test_move_mean():
    array = np.arange(100.0)
    array[::7] = np.nan

    expected = pd.Series(array).rolling(window=5, min_periods=1).mean().values
    result = move_mean(array, 5, min_count=1)
    assert_almost_equal(expected, result)
Пример #5
0
def test_move_mean_window(rand_array):

    with pytest.raises(TypeError):
        move_mean(rand_array, window=0.5)
    with pytest.raises(ValueError):
        move_mean(rand_array, window=-1)
    with pytest.raises(ValueError):
        move_mean(rand_array, window=1, min_count=-1)
Пример #6
0
def test_move_mean_window(rand_array):

    with pytest.raises(TypeError):
        move_mean(rand_array, window=0.5)
    with pytest.raises(ValueError):
        move_mean(rand_array, window=-1)
    with pytest.raises(ValueError):
        move_mean(rand_array, window=1, min_count=-1)