Commit e4716c22 authored by Aurélien Campéas's avatar Aurélien Campéas
Browse files

history: retire the deltabefore/after parameters

The only client was the staircase and now
it has its own dedicated path.
parent 8a7f2256113f
......@@ -235,21 +235,6 @@ 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.history(engine, 'append', deltabefore=pd.Timedelta(hours=1))
assert_hist("""
insertion_date value_date
2018-01-01 00:00:00+00:00 2018-01-01 00:00:00+00:00 0.0
2018-01-02 00:00:00+00:00 2018-01-02 00:00:00+00:00 1.0
2018-01-03 00:00:00+00:00 2018-01-03 00:00:00+00:00 2.0
2018-01-04 00:00:00+00:00 2018-01-04 00:00:00+00:00 3.0
2018-01-05 00:00:00+00:00 2018-01-05 00:00:00+00:00 4.0
2018-01-06 00:00:00+00:00 2018-01-06 00:00:00+00:00 5.0
2018-01-07 00:00:00+00:00 2018-01-07 00:00:00+00:00 6.0
2018-01-08 00:00:00+00:00 2018-01-08 00:00:00+00:00 7.0
2018-01-09 00:00:00+00:00 2018-01-09 00:00:00+00:00 8.0
2018-01-10 00:00:00+00:00 2018-01-10 00:00:00+00:00 9.0
""", hist)
def test_prepend(engine, tsh):
if tsh.namespace == 'z-z':
......
......@@ -813,65 +813,6 @@ insertion_date value_date
]
def test_history_delta(engine, tsh):
for d in range(1, 3):
idate = utcdt(2018, 1, d)
serie = genserie(idate - timedelta(hours=1), 'H', 6, initval=[d])
tsh.insert(engine, serie, 'hd', 'aurelien.campeas@pythonian.fr',
_insertion_date=idate)
assert_hist("""
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 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-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
2018-01-02 03:00:00+00:00 2.0
2018-01-02 04:00:00+00:00 2.0
""", tsh.history(engine, 'hd'))
assert_hist("""
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 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 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.history(engine, 'hd', deltaafter=timedelta(hours=2)))
assert_hist("""
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 01: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 01:00:00+00:00 2.0
""", tsh.history(engine, 'hd',
deltabefore=timedelta(hours=0),
deltaafter=timedelta(hours=1)))
def test_delta_na(engine, tsh):
ldates = (
utcdt(2015, 1, 20),
......@@ -1283,29 +1224,6 @@ insertion_date value_date
2015-01-01 09:00:00+00:00 6.0
""", deltas)
hist = tsh.history(engine, 'republication',
deltabefore=-timedelta(hours=3),
deltaafter=timedelta(hours=3))
assert_hist("""
insertion_date value_date
2015-01-01 00:00:00+00:00 2015-01-01 03:00:00+00:00 3.0
2015-01-01 01:00:00+00:00 2015-01-01 04:00:00+00:00 3.0
2015-01-01 02:00:00+00:00 2015-01-01 05:00:00+00:00 3.0
2015-01-01 03:00:00+00:00 2015-01-01 06:00:00+00:00 3.0
""", hist)
hist = tsh.history(engine, 'republication',
deltabefore=-timedelta(hours=5),
deltaafter=timedelta(hours=5))
assert_hist("""
insertion_date value_date
2015-01-01 00:00:00+00:00 2015-01-01 05:00:00+00:00 5.0
2015-01-01 01:00:00+00:00 2015-01-01 06:00:00+00:00 5.0
2015-01-01 02:00:00+00:00 2015-01-01 07:00:00+00:00 5.0
2015-01-01 03:00:00+00:00 2015-01-01 08:00:00+00:00 5.0
""", hist)
def test_staircase_2_tzaware(engine, tsh):
# maybe a more interesting example, each days we insert 7 data points
......@@ -1345,29 +1263,6 @@ def test_staircase_2_tzaware(engine, tsh):
2015-01-02 06:00:00+00:00 6.0
""", deltas)
# which is basically the same as below
hist = tsh.history(engine, 'repu2',
deltabefore=-timedelta(hours=3))
assert_hist("""
insertion_date value_date
2015-01-01 00:00:00+00:00 2015-01-01 03:00:00+00:00 3.0
2015-01-01 04:00:00+00:00 4.0
2015-01-01 05:00:00+00:00 5.0
2015-01-01 06:00:00+00:00 6.0
2015-01-02 00:00:00+00:00 2015-01-02 03:00:00+00:00 3.0
2015-01-02 04:00:00+00:00 4.0
2015-01-02 05:00:00+00:00 5.0
2015-01-02 06:00:00+00:00 6.0
2015-01-03 00:00:00+00:00 2015-01-03 03:00:00+00:00 3.0
2015-01-03 04:00:00+00:00 4.0
2015-01-03 05:00:00+00:00 5.0
2015-01-03 06:00:00+00:00 6.0
2015-01-04 00:00:00+00:00 2015-01-04 03:00:00+00:00 3.0
2015-01-04 04:00:00+00:00 4.0
2015-01-04 05:00:00+00:00 5.0
2015-01-04 06:00:00+00:00 6.0
""", hist)
# constrain the boundaries
deltas = tsh.staircase(engine, 'repu2',
delta=timedelta(hours=3),
......@@ -1430,29 +1325,6 @@ def test_staircase_2_tznaive(engine, tsh):
2015-01-02 06:00:00 6.0
""", deltas)
# which is basically the same as below
hist = tsh.history(engine, 'repu-tz-naive',
deltabefore=-timedelta(hours=3))
assert_hist("""
insertion_date value_date
2015-01-01 00:00:00+00:00 2015-01-01 03:00:00 3.0
2015-01-01 04:00:00 4.0
2015-01-01 05:00:00 5.0
2015-01-01 06:00:00 6.0
2015-01-02 00:00:00+00:00 2015-01-02 03:00:00 3.0
2015-01-02 04:00:00 4.0
2015-01-02 05:00:00 5.0
2015-01-02 06:00:00 6.0
2015-01-03 00:00:00+00:00 2015-01-03 03:00:00 3.0
2015-01-03 04:00:00 4.0
2015-01-03 05:00:00 5.0
2015-01-03 06:00:00 6.0
2015-01-04 00:00:00+00:00 2015-01-04 03:00:00 3.0
2015-01-04 04:00:00 4.0
2015-01-04 05:00:00 5.0
2015-01-04 06:00:00 6.0
""", hist)
# constrain the boundaries
deltas = tsh.staircase(engine, 'repu-tz-naive',
delta=timedelta(hours=3),
......
......@@ -176,8 +176,6 @@ class timeseries(SeriesServices):
to_insertion_date=None,
from_value_date=None,
to_value_date=None,
deltabefore=None,
deltaafter=None,
diffmode=False,
_wanted_insertion_dates=None,
_keep_nans=False):
......@@ -209,34 +207,11 @@ class timeseries(SeriesServices):
revs.insert(0, (previous_csid, None))
snapshot = Snapshot(cn, self, seriename)
series = []
if (deltabefore, deltaafter) != (None, None):
for csid, idate in revs:
from_date = None
to_date = None
if deltabefore is not None:
from_date = idate - deltabefore
else:
from_date = from_value_date
if deltaafter is not None:
to_date = idate + deltaafter
else:
to_date = to_value_date
series.append((
idate,
snapshot.find(
csetfilter=[
lambda q: q.where('cset.id = %(csid)s', csid=csid)
],
from_value_date=from_date,
to_value_date=to_date)[1]
)
)
else:
series = snapshot.findall(revs,
from_value_date,
to_value_date
)
series = snapshot.findall(
revs,
from_value_date,
to_value_date
)
if diffmode:
diffs = []
......
Markdown is supported
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