def test_ewm_mean(): sdf = DataFrame(example=pd.DataFrame(columns=['x', 'y'])) L = sdf.ewm(1).mean().stream.gather().sink_to_list() sdf.emit(pd.DataFrame({'x': [1.], 'y': [2.]})) sdf.emit(pd.DataFrame({'x': [2.], 'y': [3.]})) sdf.emit(pd.DataFrame({'x': [3.], 'y': [4.]})) result = pd.concat(L, ignore_index=True) df = pd.DataFrame({'x': [1., 2., 3.], 'y': [2., 3., 4.]}) expected = df.ewm(1).mean() assert_eq(result, expected)
def test_ewm_notimplemented(func): sdf = DataFrame(example=pd.DataFrame(columns=['x', 'y'])) with pytest.raises(NotImplementedError): func(sdf.ewm(1))
def test_raise_invalid_argument(arg): sdf = DataFrame(example=pd.DataFrame(columns=['x', 'y'])) param = {arg: -1} with pytest.raises(ValueError): sdf.ewm(**param)
def test_ewm_raise_no_argument(): sdf = DataFrame(example=pd.DataFrame(columns=['x', 'y'])) with pytest.raises(ValueError, match="Must pass one of"): sdf.ewm()
def test_ewm_raise_multiple_arguments(): sdf = DataFrame(example=pd.DataFrame(columns=['x', 'y'])) with pytest.raises(ValueError, match="Can only provide one of"): sdf.ewm(com=1, halflife=1)