Commit fbbc3fdd authored by Arnaud Campeas's avatar Arnaud Campeas
Browse files

get_history: only fix before/after value date when a coupling with idate is asked

parent 3affed66004a
......@@ -224,7 +224,7 @@ def test_append(engine, tsh):
1: None, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9
}
hist = tsh.get_history(engine, 'append', deltaafter=pd.Timedelta(hours=1))
hist = tsh.get_history(engine, 'append', deltabefore=pd.Timedelta(hours=1))
assert_df("""
insertion_date value_date
2018-01-01 00:00:00+00:00 2018-01-01 00:00:00+00:00 0.0
......@@ -290,7 +290,7 @@ insertion_date value_date
2018-01-18 00:00:00+00:00 2018-01-18 00:00:00+00:00 17.0
2018-01-19 00:00:00+00:00 2018-01-19 00:00:00+00:00 18.0
2018-01-20 00:00:00+00:00 2018-01-20 00:00:00+00:00 19.0
""", tsh.get_history(engine, 'append', deltaafter=pd.Timedelta(hours=1)))
""", tsh.get_history(engine, 'append', deltabefore=pd.Timedelta(hours=1)))
def test_get_from_to(engine, tsh):
......
......@@ -705,27 +705,30 @@ insertion_date value_date
assert_df("""
insertion_date value_date
2018-01-01 00:00:00+00:00 2018-01-01 00:00:00+00:00 1.0
2018-01-01 00:00:00+00:00 2017-12-31 23:00:00+00:00 1.0
2018-01-01 00:00:00+00:00 1.0
2018-01-01 01:00:00+00:00 1.0
2018-01-01 02:00:00+00:00 1.0
2018-01-02 00:00:00+00:00 2018-01-02 00:00:00+00:00 2.0
2018-01-02 00:00:00+00:00 2017-12-31 23:00:00+00:00 1.0
2018-01-01 00:00:00+00:00 1.0
2018-01-01 01:00:00+00:00 1.0
2018-01-01 02:00:00+00:00 1.0
2018-01-01 03:00:00+00:00 1.0
2018-01-01 04:00:00+00:00 1.0
2018-01-01 23:00:00+00:00 2.0
2018-01-02 00:00:00+00:00 2.0
2018-01-02 01:00:00+00:00 2.0
2018-01-02 02:00:00+00:00 2.0
""", tsh.get_history(engine, 'hd', deltaafter=timedelta(hours=2)))
# this test puts the feature in light: the value date of 23 h disapeared
# auc: I consider this a feature, but I agree we can be more liberal
assert_df("""
insertion_date value_date
2018-01-01 00:00:00+00:00 2017-12-31 23:00:00+00:00 1.0
2018-01-01 00:00:00+00:00 1.0
2018-01-01 00:00:00+00:00 2018-01-01 00:00:00+00:00 1.0
2018-01-01 01:00:00+00:00 1.0
2018-01-02 00:00:00+00:00 2018-01-01 23:00:00+00:00 2.0
2018-01-02 00:00:00+00:00 2.0
2018-01-02 00:00:00+00:00 2018-01-02 00:00:00+00:00 2.0
2018-01-02 01:00:00+00:00 2.0
""", tsh.get_history(engine, 'hd',
deltabefore=timedelta(hours=1),
deltabefore=timedelta(hours=0),
deltaafter=timedelta(hours=1)))
......
......@@ -163,12 +163,12 @@ class TimeSerie(SeriesServices):
snapshot = Snapshot(cn, self, name)
series = []
for csid, idate in revs:
if deltabefore or deltaafter:
from_value_date = idate
to_value_date = idate
if deltabefore:
if (deltabefore, deltaafter) != (None, None):
from_value_date = None
to_value_date = None
if deltabefore is not None:
from_value_date = idate - deltabefore
if deltaafter:
if deltaafter is not None:
to_value_date = idate + deltaafter
series.append((
idate,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment