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

insert: keep around a materialized version of the manual serie

We build a 'manual' namespace.

This may be useful if we want to use older versions of the original
serie but *still* keep applying the editions over it.
parent 2f153e881d2f
......@@ -21,9 +21,11 @@ def engine(request):
with e.connect() as cn:
reset(cn)
delete_schema(e, 'automatic')
delete_schema(e, 'manual')
with e.connect() as cn:
init(cn, meta)
init(cn, meta, 'automatic')
init(cn, meta, 'manual')
yield e
......
......@@ -5,6 +5,8 @@ import pytest
import pandas as pd
import numpy as np
from tshistory_supervision.tsio import TimeSerie
DATADIR = Path(__file__).parent / 'data'
......@@ -413,6 +415,14 @@ def test_more_manual(engine, tsh):
2015-01-05 True
""", marker)
tshm = TimeSerie('manual')
man = tshm.get(engine, 'ts_exp1', _keep_nans=True)
assert_df("""
2015-01-03 -3.0
2015-01-04 -3.0
2015-01-05 NaN
""", man)
def test_before_first_insertion(engine, tsh):
tsh.insert(engine, genserie(datetime(2010, 1, 1), 'D', 11), 'ts_shtroumpf', 'test')
......
......@@ -54,19 +54,25 @@ class TimeSerie(BaseTS):
def insert(self, cn, ts, name, author, _insertion_date=None, manual=False):
if manual:
basetsh = BaseTS(namespace='manual')
# insert & compute diff over synthetic
return super().insert(
diff = basetsh.insert(
cn, ts, name, author, _insertion_date=_insertion_date
)
# insert into synthetic & compute diff over automatic
basetsh = BaseTS(namespace='automatic')
diff = basetsh.insert(
cn, ts, name, author,
_insertion_date=_insertion_date
)
if diff is None:
return
if diff is None:
return
diff = ts
else:
# insert into synthetic & compute diff over automatic
basetsh = BaseTS(namespace='automatic')
diff = basetsh.insert(
cn, ts, name, author,
_insertion_date=_insertion_date
)
if diff is None:
return
# insert the diff over automatic into synthetic
a = super().insert(
......
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