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
bfaba10d
Commit
bfaba10d
authored
11 months ago
by
David Schäfer
Browse files
Options
Downloads
Patches
Plain Diff
undo changes to FloatScheme
parent
470393e6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!842
Annotated float scheme
Pipeline
#206291
failed with stages
in 3 minutes and 48 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
saqc/core/translation/floatscheme.py
+22
-10
22 additions, 10 deletions
saqc/core/translation/floatscheme.py
tests/core/test_translator.py
+2
-4
2 additions, 4 deletions
tests/core/test_translator.py
tests/funcs/test_flagtools.py
+8
-8
8 additions, 8 deletions
tests/funcs/test_flagtools.py
with
32 additions
and
22 deletions
saqc/core/translation/floatscheme.py
+
22
−
10
View file @
bfaba10d
...
...
@@ -11,27 +11,39 @@ from __future__ import annotations
import
numpy
as
np
import
pandas
as
pd
from
saqc.constants
import
UNFLAGGED
from
saqc.constants
import
FILTER_ALL
,
UNFLAGGED
from
saqc.core.flags
import
Flags
from
saqc.core.frame
import
DictOfSeries
from
saqc.core.history
import
History
from
saqc.core.translation.basescheme
import
Mapping
Scheme
from
saqc.core.translation.basescheme
import
Translation
Scheme
class
FloatScheme
(
Mapping
Scheme
):
class
FloatScheme
(
Translation
Scheme
):
"""
Acts as the default Translator, provides a changeable subset of the
internal float flags
"""
_MAP
=
{
np
.
nan
:
np
.
nan
,
-
np
.
inf
:
-
np
.
inf
,
**
{
k
:
k
for
k
in
np
.
arange
(
0
,
256
,
dtype
=
float
)},
}
DFILTER_DEFAULT
:
float
=
FILTER_ALL
def
__init__
(
self
):
super
().
__init__
(
forward
=
self
.
_MAP
,
backward
=
self
.
_MAP
)
def
__call__
(
self
,
flag
:
float
|
int
)
->
float
:
try
:
return
float
(
flag
)
except
(
TypeError
,
ValueError
,
OverflowError
):
raise
ValueError
(
f
"
invalid flag, expected a numerical value, got:
{
flag
}
"
)
def
toInternal
(
self
,
flags
:
pd
.
DataFrame
|
DictOfSeries
)
->
Flags
:
try
:
return
Flags
(
flags
.
astype
(
float
))
except
(
TypeError
,
ValueError
,
OverflowError
):
raise
ValueError
(
f
"
invalid flag(s), expected a collection of numerical values, got:
{
flags
}
"
)
def
toExternal
(
self
,
flags
:
Flags
,
attrs
:
dict
|
None
=
None
)
->
DictOfSeries
:
out
=
DictOfSeries
(
flags
)
out
.
attrs
=
attrs
or
{}
return
out
class
AnnotatedFloatScheme
(
FloatScheme
):
...
...
This diff is collapsed.
Click to expand it.
tests/core/test_translator.py
+
2
−
4
View file @
bfaba10d
...
...
@@ -13,8 +13,8 @@ import numpy as np
import
pandas
as
pd
import
pytest
from
saqc
import
BAD
,
DOUBTFUL
,
FILTER_NONE
,
UNFLAGGED
,
SaQC
from
saqc.core
import
Flags
from
saqc
.constants
import
BAD
,
DOUBTFUL
,
FILTER_NONE
,
UNFLAGGED
from
saqc.core
import
Flags
,
SaQC
from
saqc.core.translation
import
DmpScheme
,
MappingScheme
,
PositionalScheme
from
saqc.core.translation.floatscheme
import
AnnotatedFloatScheme
from
tests.common
import
initData
...
...
@@ -291,8 +291,6 @@ def test_annotatedFloatScheme():
)
flags
=
saqc
.
flags
qfunc
=
pd
.
DataFrame
({
k
:
v
[
"
func
"
]
for
k
,
v
in
flags
.
items
()})
assert
flags
[
col
][
"
flag
"
].
isin
({
DOUBTFUL
,
BAD
,
UNFLAGGED
}).
all
(
axis
=
None
)
assert
flags
[
col
][
"
func
"
].
isin
({
""
,
"
setFlags
"
,
"
flagRange
"
}).
all
(
axis
=
None
)
...
...
This diff is collapsed.
Click to expand it.
tests/funcs/test_flagtools.py
+
8
−
8
View file @
bfaba10d
...
...
@@ -48,24 +48,24 @@ N = np.nan
([
B
,
U
,
U
,
U
,
U
],
[
N
,
N
,
N
,
N
,
N
],
{
"
window
"
:
"
10D
"
,
"
method
"
:
"
bfill
"
}),
# playing with dfilter
(
[
2
,
B
,
0
,
0
,
0
],
[
1
,
B
,
-
1
,
-
1
,
-
1
],
[
N
,
N
,
B
,
B
,
N
],
{
"
window
"
:
2
,
"
method
"
:
"
ffill
"
,
"
dfilter
"
:
1
},
{
"
window
"
:
2
,
"
method
"
:
"
ffill
"
,
"
dfilter
"
:
0
},
),
(
[
0
,
0
,
0
,
B
,
2
],
[
-
1
,
-
1
,
-
1
,
B
,
1
],
[
N
,
B
,
B
,
N
,
N
],
{
"
window
"
:
2
,
"
method
"
:
"
bfill
"
,
"
dfilter
"
:
1
},
{
"
window
"
:
2
,
"
method
"
:
"
bfill
"
,
"
dfilter
"
:
0
},
),
(
[
B
,
2
,
0
,
2
,
2
],
[
B
,
1
,
-
1
,
1
,
1
],
[
N
,
N
,
B
,
N
,
N
],
{
"
window
"
:
"
2D
"
,
"
method
"
:
"
ffill
"
,
"
dfilter
"
:
1
},
{
"
window
"
:
"
2D
"
,
"
method
"
:
"
ffill
"
,
"
dfilter
"
:
0
},
),
(
[
B
,
2
,
2
,
0
,
2
],
[
B
,
1
,
1
,
-
1
,
1
],
[
N
,
N
,
N
,
B
,
N
],
{
"
window
"
:
"
2D
"
,
"
method
"
:
"
bfill
"
,
"
dfilter
"
:
1
},
{
"
window
"
:
"
2D
"
,
"
method
"
:
"
bfill
"
,
"
dfilter
"
:
0
},
),
],
)
...
...
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