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
555f5251
Commit
555f5251
authored
1 year ago
by
David Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
working on - multi field, single target generates to many empty history columns
parent
d339e348
No related branches found
No related tags found
1 merge request
!801
Make transferFlags a multivariate function
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
saqc/core/history.py
+3
-0
3 additions, 0 deletions
saqc/core/history.py
saqc/funcs/flagtools.py
+8
-2
8 additions, 2 deletions
saqc/funcs/flagtools.py
saqc/lib/tools.py
+3
-1
3 additions, 1 deletion
saqc/lib/tools.py
tests/funcs/test_flagtools.py
+23
-0
23 additions, 0 deletions
tests/funcs/test_flagtools.py
with
37 additions
and
3 deletions
saqc/core/history.py
+
3
−
0
View file @
555f5251
...
...
@@ -435,6 +435,9 @@ class History:
new
.
_meta
=
copyfunc
(
self
.
_meta
)
return
new
def
equals
(
self
,
other
:
History
)
->
bool
:
return
self
.
_hist
.
equals
(
other
.
_hist
)
and
self
.
meta
==
other
.
meta
def
__copy__
(
self
):
return
self
.
copy
(
deep
=
False
)
...
...
This diff is collapsed.
Click to expand it.
saqc/funcs/flagtools.py
+
8
−
2
View file @
555f5251
...
...
@@ -17,6 +17,7 @@ from typing_extensions import Literal
from
saqc
import
BAD
,
FILTER_ALL
,
UNFLAGGED
from
saqc.core
import
DictOfSeries
,
flagging
,
register
from
saqc.core.flags
import
Flags
from
saqc.core.history
import
History
from
saqc.lib.checking
import
validateChoice
,
validateWindow
from
saqc.lib.tools
import
initializeTargets
,
isflagged
,
isunflagged
,
multivariateParameters
,
toSequence
...
...
@@ -355,6 +356,10 @@ class FlagtoolsMixin:
for
field
,
target
in
zip
(
fields
,
targets
):
if
target
not
in
self
.
_data
:
self
.
_data
[
target
]
=
pd
.
Series
(
np
.
nan
,
index
=
self
.
_data
[
field
].
index
)
self
.
_flags
.
_data
[
target
]
=
History
(
self
.
_data
[
target
].
index
)
history
=
self
.
_flags
.
history
[
field
]
# append a dummy column
meta
=
{
...
...
@@ -380,8 +385,9 @@ class FlagtoolsMixin:
else
:
flags
=
pd
.
Series
(
np
.
nan
,
index
=
history
.
index
,
dtype
=
float
)
history
.
append
(
flags
,
meta
)
self
.
_flags
.
history
[
target
].
append
(
history
)
history
.
append
(
flags
,
meta
)
self
.
_flags
.
history
[
target
].
append
(
history
)
import
ipdb
;
ipdb
.
set_trace
()
return
self
...
...
This diff is collapsed.
Click to expand it.
saqc/lib/tools.py
+
3
−
1
View file @
555f5251
...
...
@@ -654,7 +654,9 @@ def joinExt(sep: str, iterable: Iterable[str], last_sep: str | None = None) -> s
return
f
"
{
sep
.
join
(
iterable
[
:
-
1
])
}{
last_sep
}{
iterable
[
-
1
]
}
"
def
multivariateParameters
(
field
:
str
|
list
[
str
],
target
:
str
|
list
[
str
]
|
None
=
None
)
->
tuple
[
list
[
str
],
list
[
str
]]:
def
multivariateParameters
(
field
:
str
|
list
[
str
],
target
:
str
|
list
[
str
]
|
None
=
None
)
->
tuple
[
list
[
str
],
list
[
str
]]:
fields
=
toSequence
(
field
)
targets
=
fields
if
target
is
None
else
toSequence
(
target
)
...
...
This diff is collapsed.
Click to expand it.
tests/funcs/test_flagtools.py
+
23
−
0
View file @
555f5251
...
...
@@ -175,3 +175,26 @@ def test__groupOperation(field, target, expected, copy):
fields
=
toSequence
(
itertools
.
chain
.
from_iterable
(
field
))
for
f
,
t
in
zip
(
fields
,
targets
):
assert
(
result
.
_data
[
f
]
==
result
.
_data
[
t
]).
all
(
axis
=
None
)
def
test_transferFlags
():
qc
=
SaQC
(
data
=
pd
.
DataFrame
(
{
"
x
"
:
[
0
,
1
,
2
,
3
],
"
y
"
:
[
0
,
11
,
22
,
33
],
"
z
"
:
[
0
,
111
,
222
,
333
]}
),
flags
=
pd
.
DataFrame
({
"
x
"
:
[
B
,
U
,
U
,
B
],
"
y
"
:
[
B
,
B
,
U
,
U
],
"
z
"
:
[
B
,
B
,
U
,
B
]}),
)
# qc1 = qc.transferFlags("x", target="a")
# assert qc1._history["a"].equals(qc1._history["x"])
# qc2 = qc.transferFlags(["x", "y"], target=["a", "b"])
# assert qc2._history["a"].equals(qc2._history["x"])
# assert qc2._history["b"].equals(qc2._history["y"])
qc3
=
qc
.
transferFlags
([
"
x
"
,
"
y
"
,
"
z
"
],
target
=
"
a
"
)
import
ipdb
;
ipdb
.
set_trace
()
assert
qc3
.
_history
[
"
a
"
].
equals
(
qc2
.
_history
[
"
x
"
].
append
(
qc2
.
_history
[
"
y
"
]).
append
(
qc2
.
_history
[
"
z
"
]))
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