Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
pony
tshistory
Commits
8a7f2256113f
Commit
a941b57b
authored
Jul 19, 2019
by
Aurélien Campéas
Browse files
history: prune successive items showing no difference
parent
106e7570b1bc
Changes
3
Show whitespace changes
Inline
Side-by-side
test/test_tsio.py
View file @
8a7f2256
...
...
@@ -774,8 +774,6 @@ insertion_date value_date
2017-02-01 00:00:00+00:00 2017-01-01 0.0
2017-02-02 00:00:00+00:00 2017-01-01 0.0
2017-01-02 1.0
2017-02-03 00:00:00+00:00 2017-01-01 0.0
2017-01-02 1.0
"""
,
tsc
)
tsc
=
tsh
.
history
(
engine
,
'smallserie'
,
...
...
@@ -794,8 +792,6 @@ insertion_date value_date
2017-02-01 00:00:00+00:00 2017-01-01 0.0
2017-02-02 00:00:00+00:00 2017-01-01 0.0
2017-01-02 1.0
2017-02-03 00:00:00+00:00 2017-01-01 0.0
2017-01-02 1.0
"""
,
tsc
)
tsc
=
tsh
.
history
(
engine
,
'no-such-series'
)
...
...
tshistory/tsio.py
View file @
8a7f2256
...
...
@@ -14,6 +14,7 @@ from sqlhelp import sqlfile, select
from
tshistory.util
import
(
closed_overlaps
,
num2float
,
pruned_history
,
SeriesServices
,
start_end
,
tx
,
...
...
@@ -255,11 +256,19 @@ class timeseries(SeriesServices):
for
idate
,
ts
in
series
]
return
{
hist
=
{
idate
:
ts
for
idate
,
ts
in
series
if
len
(
series
)
}
if
from_value_date
or
to_value_date
:
# now it's possible that the extremities cut
# yields similar series for successive idates
# and we are not interested in that
hist
=
pruned_history
(
hist
)
return
hist
@
tx
def
staircase
(
self
,
cn
,
seriename
,
delta
,
from_value_date
=
None
,
...
...
tshistory/util.py
View file @
8a7f2256
...
...
@@ -66,6 +66,23 @@ def tzaware_serie(ts):
return
is_datetime64tz_dtype
(
ts
.
index
)
def
pruned_history
(
hist
):
if
not
hist
:
return
hist
idates
=
list
(
hist
.
keys
())
idate
=
idates
[
0
]
current
=
hist
[
idate
]
pruned
=
{
idate
:
current
}
for
idate
in
idates
[
1
:]:
newts
=
hist
[
idate
]
if
not
current
.
equals
(
newts
):
pruned
[
idate
]
=
newts
current
=
newts
return
pruned
def
start_end
(
ts
,
notz
=
True
):
ts
=
ts
.
dropna
()
if
not
len
(
ts
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment