Commit 8fde90fe authored by Arnaud Campeas's avatar Arnaud Campeas
Browse files

tsio: transform int64 to float64 at insertion of a new time serie

parent d2fa1f92f6c5
......@@ -173,11 +173,11 @@ def test_differential(engine):
# -1 represents bogus upstream data
assert """
2010-01-01 2
2010-01-02 2
2010-01-03 2
2010-01-04 -1
2010-01-05 2
2010-01-01 2.0
2010-01-02 2.0
2010-01-03 2.0
2010-01-04 -1.0
2010-01-05 2.0
""".strip() == tso.get(engine, 'ts_mixte').to_string().strip()
# refresh all the period + 1 extra data point
......@@ -274,7 +274,7 @@ def test_bad_import(engine):
tso.insert(engine, ts, 'SND_SC', 'test')
result = tso.get(engine, 'SND_SC')
assert result.dtype == 'int64'
assert result.dtype == 'float64'
# insertion of empty ts
ts = pd.Series(name='truc', dtype='object')
......@@ -342,30 +342,30 @@ def test_revision_date(engine):
ts = tso.get(engine, 'ts_through_time')
assert """
2010-01-04 3
2010-01-05 3
2010-01-06 3
2010-01-07 3
2010-01-04 3.0
2010-01-05 3.0
2010-01-06 3.0
2010-01-07 3.0
""".strip() == ts.to_string().strip()
ts = tso.get(engine, 'ts_through_time',
revision_date=datetime(2015, 1, 2, 18, 43, 23) )
assert """
2010-01-04 2
2010-01-05 2
2010-01-06 2
2010-01-07 2
2010-01-04 2.0
2010-01-05 2.0
2010-01-06 2.0
2010-01-07 2.0
""".strip() == ts.to_string().strip()
ts = tso.get(engine, 'ts_through_time',
revision_date=datetime(2015, 1, 1, 18, 43, 23))
assert """
2010-01-04 1
2010-01-05 1
2010-01-06 1
2010-01-07 1
2010-01-04 1.0
2010-01-05 1.0
2010-01-06 1.0
2010-01-07 1.0
""".strip() == ts.to_string().strip()
ts = tso.get(engine, 'ts_through_time',
......
......@@ -60,7 +60,7 @@ class TimeSerie(object):
extra_scalars={}):
"""Create a new revision of a given time series
newts: pandas.Series with date index and float values
newts: pandas.Series with date index
name: str unique identifier of the serie
......@@ -73,6 +73,8 @@ class TimeSerie(object):
L.info('author will not be used when in a changeset')
assert isinstance(newts, pd.Series)
if newts.dtype == 'int64':
newts = newts.astype('float64')
newts = newts[~newts.isnull()] # wipe the the NaNs
if not len(newts):
return
......
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