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
8af7adb2
Commit
8af7adb2
authored
4 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
removed iterable support
parent
1e5d48c4
No related branches found
No related tags found
1 merge request
!218
Flags
Pipeline
#17538
passed with stage
Stage: test
in 6 minutes and 26 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
saqc/flagger/flags.py
+8
-21
8 additions, 21 deletions
saqc/flagger/flags.py
with
8 additions
and
21 deletions
saqc/flagger/flags.py
+
8
−
21
View file @
8af7adb2
...
@@ -6,16 +6,14 @@ import dios
...
@@ -6,16 +6,14 @@ import dios
from
saqc.common
import
*
from
saqc.common
import
*
from
saqc.flagger.history
import
History
from
saqc.flagger.history
import
History
import
pandas
as
pd
import
pandas
as
pd
from
typing
import
Union
,
Dict
,
DefaultDict
,
Iterable
,
Tuple
,
Optional
,
Type
from
typing
import
Union
,
Dict
,
DefaultDict
,
Optional
,
Type
_KEY
=
str
_VAL
=
Union
[
pd
.
Series
,
History
]
_VAL
=
Union
[
pd
.
Series
,
History
]
_
DictLike
=
Union
[
DictLike
=
Union
[
pd
.
DataFrame
,
pd
.
DataFrame
,
dios
.
DictOfSeries
,
dios
.
DictOfSeries
,
Dict
[
_KEY
,
_VAL
],
Dict
[
str
,
_VAL
],
DefaultDict
[
_KEY
,
_VAL
],
DefaultDict
[
str
,
_VAL
],
Iterable
[
Tuple
[
_KEY
,
_VAL
]]
]
]
...
@@ -63,7 +61,7 @@ class Flags:
...
@@ -63,7 +61,7 @@ class Flags:
make a df -> flags.to_frame()
make a df -> flags.to_frame()
"""
"""
def
__init__
(
self
,
raw_data
:
Optional
[
Union
[
_
DictLike
,
Flags
]]
=
None
,
copy
:
bool
=
False
):
def
__init__
(
self
,
raw_data
:
Optional
[
Union
[
DictLike
,
Flags
]]
=
None
,
copy
:
bool
=
False
):
if
raw_data
is
None
:
if
raw_data
is
None
:
raw_data
=
{}
raw_data
=
{}
...
@@ -88,12 +86,7 @@ class Flags:
...
@@ -88,12 +86,7 @@ class Flags:
"""
"""
result
=
{}
result
=
{}
for
obj
in
data
:
for
k
,
item
in
data
.
items
():
if
isinstance
(
obj
,
tuple
):
k
,
item
=
obj
else
:
k
,
item
=
obj
,
data
[
obj
]
if
k
in
result
:
if
k
in
result
:
raise
ValueError
(
'
raw_data must not have duplicate keys
'
)
raise
ValueError
(
'
raw_data must not have duplicate keys
'
)
...
@@ -267,7 +260,7 @@ class Flags:
...
@@ -267,7 +260,7 @@ class Flags:
return
str
(
self
.
to_dios
()).
replace
(
'
DictOfSeries
'
,
type
(
self
).
__name__
)
return
str
(
self
.
to_dios
()).
replace
(
'
DictOfSeries
'
,
type
(
self
).
__name__
)
def
init_flags_like
(
reference
:
Union
[
pd
.
Series
,
_
DictLike
,
Flags
],
initial_value
:
float
=
UNFLAGGED
)
->
Flags
:
def
init_flags_like
(
reference
:
Union
[
pd
.
Series
,
DictLike
,
Flags
],
initial_value
:
float
=
UNFLAGGED
)
->
Flags
:
"""
"""
Create empty Flags, from an reference data structure.
Create empty Flags, from an reference data structure.
...
@@ -301,13 +294,7 @@ def init_flags_like(reference: Union[pd.Series, _DictLike, Flags], initial_value
...
@@ -301,13 +294,7 @@ def init_flags_like(reference: Union[pd.Series, _DictLike, Flags], initial_value
if
isinstance
(
reference
,
pd
.
Series
):
if
isinstance
(
reference
,
pd
.
Series
):
reference
=
reference
.
to_frame
(
'
f0
'
)
reference
=
reference
.
to_frame
(
'
f0
'
)
for
obj
in
reference
:
for
k
,
item
in
reference
.
items
():
# unpack
if
isinstance
(
obj
,
tuple
):
k
,
item
=
obj
else
:
k
,
item
=
obj
,
reference
[
obj
]
if
not
isinstance
(
k
,
str
):
if
not
isinstance
(
k
,
str
):
raise
TypeError
(
f
"
cannot use
{
k
}
as key, currently only string keys are allowed
"
)
raise
TypeError
(
f
"
cannot use
{
k
}
as key, currently only string keys are allowed
"
)
...
...
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