def test_from_values_exception(index, values): with pytest.raises(ValueError): Stairs.from_values( initial_value=0, values=pd.Series(values, index=index), closed="left", )
def test_from_values_exception(index, values): with pytest.raises(ValueError): kwargs = {"dtype": "float64"} if values == [] else {} Stairs.from_values( initial_value=0, values=pd.Series(values, index=index, **kwargs), closed="left", )
def test_from_values(initial_value, closed): # this corresponds to the step function produced by S1 method values = pd.Series([-1.75, 0.25, 2.75, 2.00, -0.5, 0], index=[-4, 1, 3, 5, 6, 10]) sf = Stairs.from_values( initial_value=initial_value, values=values + initial_value, closed=closed, ) assert sf.identical(s1(closed) + initial_value)
def test_from_values(date_func): # this corresponds to the step function produced by S1 method values = pd.Series( [2, 4.5, 2, -0.5, 0], index=[ timestamp(2020, 1, 1, date_func=date_func), timestamp(2020, 1, 3, date_func=date_func), timestamp(2020, 1, 5, date_func=date_func), timestamp(2020, 1, 6, date_func=date_func), timestamp(2020, 1, 10, date_func=date_func), ], ) sf = Stairs.from_values( initial_value=0, values=values, ) print(sf._data) print(s1(date_func)._data) assert sf.identical(s1(date_func))