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
3737e639
Commit
3737e639
authored
4 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
fixed init's
parent
df3dbe9e
No related branches found
No related tags found
1 merge request
!218
Flags
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
saqc/flagger/flags.py
+12
-2
12 additions, 2 deletions
saqc/flagger/flags.py
with
12 additions
and
2 deletions
saqc/flagger/flags.py
+
12
−
2
View file @
3737e639
...
@@ -92,6 +92,7 @@ class Flags:
...
@@ -92,6 +92,7 @@ class Flags:
result
=
{}
result
=
{}
for
obj
in
data
:
for
obj
in
data
:
if
isinstance
(
obj
,
tuple
):
if
isinstance
(
obj
,
tuple
):
k
,
item
=
obj
k
,
item
=
obj
else
:
else
:
...
@@ -102,6 +103,10 @@ class Flags:
...
@@ -102,6 +103,10 @@ class Flags:
if
isinstance
(
item
,
pd
.
Series
):
if
isinstance
(
item
,
pd
.
Series
):
item
=
item
.
to_frame
(
name
=
0
)
item
=
item
.
to_frame
(
name
=
0
)
elif
isinstance
(
item
,
History
):
pass
else
:
raise
TypeError
(
f
"
cannot init from
{
type
(
data
.
__name__
)
}
of
{
type
(
item
.
__name__
)
}
"
)
result
[
k
]
=
History
(
item
,
copy
=
copy
)
result
[
k
]
=
History
(
item
,
copy
=
copy
)
...
@@ -140,17 +145,21 @@ class Flags:
...
@@ -140,17 +145,21 @@ class Flags:
def
columns
(
self
,
value
:
pd
.
Index
):
def
columns
(
self
,
value
:
pd
.
Index
):
if
not
isinstance
(
value
,
pd
.
Index
):
if
not
isinstance
(
value
,
pd
.
Index
):
value
=
pd
.
Index
(
value
)
value
=
pd
.
Index
(
value
)
if
(
if
(
not
value
.
is_unique
not
value
.
is_unique
or
not
pd
.
api
.
types
.
is_string_dtype
(
value
)
or
not
pd
.
api
.
types
.
is_string_dtype
(
value
)
):
):
raise
TypeError
(
'
value must be pd.Index, with unique indices of type str
'
)
raise
TypeError
(
'
value must be pd.Index, with unique indices of type str
'
)
if
not
len
(
value
)
==
len
(
self
):
if
not
len
(
value
)
==
len
(
self
):
raise
ValueError
(
"
index must match current index in length
"
)
raise
ValueError
(
"
index must match current index in length
"
)
_data
,
_cache
=
{},
{}
_data
,
_cache
=
{},
{}
for
old
,
new
in
zip
(
self
.
columns
,
value
):
for
old
,
new
in
zip
(
self
.
columns
,
value
):
_data
[
new
]
=
self
.
_data
.
pop
(
old
)
_data
[
new
]
=
self
.
_data
.
pop
(
old
)
if
old
in
self
.
_cache
:
if
old
in
self
.
_cache
:
_cache
[
new
]
=
self
.
_cache
[
old
]
_cache
[
new
]
=
self
.
_cache
[
old
]
...
@@ -234,7 +243,7 @@ def init_flags_like(reference: Union[pd.Series, DictLike, Flags], initial_value:
...
@@ -234,7 +243,7 @@ def init_flags_like(reference: Union[pd.Series, DictLike, Flags], initial_value:
if
not
isinstance
(
item
,
(
pd
.
Series
,
History
)):
if
not
isinstance
(
item
,
(
pd
.
Series
,
History
)):
raise
TypeError
(
'
items in reference must be of type pd.Series
'
)
raise
TypeError
(
'
items in reference must be of type pd.Series
'
)
item
=
pd
.
DataFrame
(
UNFLAGGED
,
index
=
item
.
index
,
columns
=
[
0
],
dtype
=
float
)
item
=
pd
.
DataFrame
(
initial_value
,
index
=
item
.
index
,
columns
=
[
0
],
dtype
=
float
)
result
[
k
]
=
History
(
item
)
result
[
k
]
=
History
(
item
)
...
@@ -244,6 +253,7 @@ def init_flags_like(reference: Union[pd.Series, DictLike, Flags], initial_value:
...
@@ -244,6 +253,7 @@ def init_flags_like(reference: Union[pd.Series, DictLike, Flags], initial_value:
if
__name__
==
'
__main__
'
:
if
__name__
==
'
__main__
'
:
from
dios
import
example_DictOfSeries
from
dios
import
example_DictOfSeries
f
=
init_flags_like
(
example_DictOfSeries
())
f
=
init_flags_like
(
example_DictOfSeries
()
,
initial_value
=-
3.
)
print
(
f
)
print
(
f
)
print
(
Flags
())
print
(
Flags
())
print
(
Flags
(
example_DictOfSeries
().
astype
(
float
)))
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