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

insert: sort the series if needed

This is more helpful.
parent 31d84f3e5041
......@@ -1323,9 +1323,9 @@ def test_rename(engine, tsh):
def test_index_order(engine, tsh):
ts = genserie(datetime(2020, 1, 1), 'D', 3)
with pytest.raises(AssertionError):
tsh.insert(engine, ts.sort_index(ascending=False),
'test_order', 'babar')
# will be sorted for us as needed
tsh.insert(engine, ts.sort_index(ascending=False),
'test_order', 'babar')
def test_parallel(engine, tsh):
......
......@@ -57,7 +57,9 @@ class TimeSerie(SeriesServices):
assert metadata is None or isinstance(metadata, dict), 'Bad format for metadata'
assert _insertion_date is None or isinstance(_insertion_date, datetime), 'Bad format for insertion date'
assert not newts.index.duplicated().any(), 'There are some duplicates in the index'
assert newts.index.is_monotonic_increasing, 'The index is not monotonic'
if not newts.index.is_monotonic_increasing:
newts = newts.sort_index()
newts = num2float(newts)
......
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