Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
SaQC
Manage
Activity
Members
Labels
Plan
Issues
36
Issue boards
Milestones
Wiki
Code
Merge requests
8
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
rdm-software
SaQC
Commits
0586093a
Commit
0586093a
authored
1 year ago
by
David Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
added option to change History.squeeze behavior
parent
16070353
No related branches found
No related tags found
1 merge request
!826
added option to change History.squeeze behavior
Pipeline
#204404
failed with stages
in 3 minutes and 58 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+1
-0
1 addition, 0 deletions
CHANGELOG.md
saqc/core/history.py
+8
-1
8 additions, 1 deletion
saqc/core/history.py
tests/core/test_history.py
+22
-1
22 additions, 1 deletion
tests/core/test_history.py
with
31 additions
and
2 deletions
CHANGELOG.md
+
1
−
0
View file @
0586093a
...
...
@@ -19,6 +19,7 @@ SPDX-License-Identifier: GPL-3.0-or-later
-
`plot`
: added
`yscope`
keyword
-
`setFlags`
: function to replace
`flagManual`
-
`flagUniLOF`
: added defaultly applied correction to mitigate phenomenon of overflagging at relatively steep data value slopes. (parameter
`slope_correct`
).
-
`History`
: added option to change aggregation behavior
### Changed
### Removed
### Fixed
...
...
This diff is collapsed.
Click to expand it.
saqc/core/history.py
+
8
−
1
View file @
0586093a
...
...
@@ -15,6 +15,13 @@ from pandas.api.types import is_float_dtype
from
saqc
import
UNFLAGGED
AGGRGEGATIONS
=
{
"
last
"
:
lambda
x
:
x
.
ffill
(
axis
=
1
).
iloc
[:,
-
1
],
"
max
"
:
lambda
x
:
x
.
max
(
axis
=
1
),
"
min
"
:
lambda
x
:
x
.
min
(
axis
=
1
),
}
AGGREGATION
=
"
last
"
class
History
:
"""
...
...
@@ -306,7 +313,7 @@ class History:
if
hist
.
empty
:
result
=
pd
.
Series
(
data
=
np
.
nan
,
index
=
self
.
_hist
.
index
,
dtype
=
float
)
else
:
result
=
hist
.
ffill
(
axis
=
1
).
iloc
[:,
-
1
]
result
=
AGGRGEGATIONS
[
AGGREGATION
](
hist
)
if
not
raw
:
result
=
result
.
fillna
(
UNFLAGGED
)
result
.
name
=
None
...
...
This diff is collapsed.
Click to expand it.
tests/core/test_history.py
+
22
−
1
View file @
0586093a
...
...
@@ -9,7 +9,7 @@ import pandas as pd
import
pytest
from
pandas.api.types
import
is_categorical_dtype
,
is_float_dtype
from
saqc.core.history
import
History
,
createHistoryFromData
from
saqc.core.history
import
AGGREGATION
,
History
,
createHistoryFromData
from
tests.common
import
dummyHistory
# see #GH143 combined backtrack
...
...
@@ -240,3 +240,24 @@ def test_append_force(__hist, s, max_val):
hist
.
append
(
s
)
check_invariants
(
hist
)
assert
all
(
hist
.
squeeze
()
==
max_val
)
@pytest.mark.parametrize
(
"
col, expected
"
,
[
(
pd
.
Series
(
0
,
index
=
range
(
6
),
dtype
=
float
),
{
"
last
"
:
0
,
"
min
"
:
0
,
"
max
"
:
0
}),
(
pd
.
Series
(
1
,
index
=
range
(
6
),
dtype
=
float
),
{
"
last
"
:
1
,
"
min
"
:
0
,
"
max
"
:
1
}),
(
pd
.
Series
(
6
,
index
=
range
(
6
),
dtype
=
float
),
{
"
last
"
:
6
,
"
min
"
:
0
,
"
max
"
:
6
}),
(
pd
.
Series
(
4
,
index
=
range
(
6
),
dtype
=
float
),
{
"
last
"
:
4
,
"
min
"
:
0
,
"
max
"
:
6
}),
],
)
def
test_aggregations
(
__hist
,
col
,
expected
):
import
saqc.core.history
hist
=
__hist
hist
.
append
(
col
)
check_invariants
(
hist
)
for
aggregation
in
[
"
last
"
,
"
min
"
,
"
max
"
]:
saqc
.
core
.
history
.
AGGREGATION
=
aggregation
hist
.
_aggregation
=
aggregation
assert
(
hist
.
squeeze
()
==
expected
[
aggregation
]).
all
()
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment