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
3a1b71af
Commit
3a1b71af
authored
5 years ago
by
Bert Palm
🎇
Browse files
Options
Downloads
Patches
Plain Diff
rm positional flagger
parent
e5ae35d4
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
saqc/__init__.py
+1
-1
1 addition, 1 deletion
saqc/__init__.py
saqc/flagger/__init__.py
+1
-2
1 addition, 2 deletions
saqc/flagger/__init__.py
saqc/flagger/positionalflagger.py
+0
-90
0 additions, 90 deletions
saqc/flagger/positionalflagger.py
with
2 additions
and
93 deletions
saqc/__init__.py
+
1
−
1
View file @
3a1b71af
...
...
@@ -2,4 +2,4 @@
# -*- coding: utf-8 -*-
from
.core
import
runner
from
.flagger
import
DmpFlagger
,
PositionalFlagger
,
SimpleFlagger
,
BaseFlagger
from
.flagger
import
*
This diff is collapsed.
Click to expand it.
saqc/flagger/__init__.py
+
1
−
2
View file @
3a1b71af
...
...
@@ -2,7 +2,6 @@
# -*- coding: utf-8 -*-
from
.template
import
FlaggerTemplate
from
.baseflagger
import
BaseFlagger
from
.simpleflagger
import
SimpleFlagger
from
.dmpflagger
import
DmpFlagger
from
.positionalflagger
import
PositionalFlagger
from
.baseflagger
import
BaseFlagger
This diff is collapsed.
Click to expand it.
saqc/flagger/positionalflagger.py
deleted
100644 → 0
+
0
−
90
View file @
e5ae35d4
#! /usr/bin/env python
# -*- coding: utf-8 -*-
from
numbers
import
Number
from
typing
import
Union
,
Sequence
,
Any
,
Optional
import
numpy
as
np
import
pandas
as
pd
from
.baseflagger
import
BaseFlagger
from
..lib.tools
import
numpyfy
,
broadcastMany
from
..lib.types
import
ArrayLike
class
PositionalFlagger
(
BaseFlagger
):
def
__init__
(
self
,
no_flag
=
9
,
critical_flag
=
2
):
super
().
__init__
(
no_flag
=
no_flag
,
flag
=
critical_flag
)
self
.
_flag_pos
=
1
self
.
_initial_flag_pos
=
1
def
nextTest
(
self
):
self
.
_flag_pos
+=
1
def
setFlag
(
self
,
flags
:
ArrayLike
,
flag
:
Optional
[
int
]
=
None
,
flagpos
:
Optional
[
int
]
=
None
,
**
kwargs
:
Any
)
->
np
.
ndarray
:
if
flag
is
None
:
flag
=
self
.
flag
if
flagpos
is
None
:
flagpos
=
self
.
_flag_pos
return
self
.
_writeFlags
(
flags
,
flag
,
flagpos
)
def
isFlagged
(
self
,
flags
,
flag
=
None
):
maxflags
=
self
.
_getMaxflags
(
flags
[
np
.
isfinite
(
flags
)])
if
flag
is
None
:
return
(
pd
.
notnull
(
maxflags
)
&
(
maxflags
!=
self
.
no_flag
))
return
maxflags
==
flag
def
_getMaxflags
(
self
,
flags
:
pd
.
DataFrame
,
exclude
:
Union
[
int
,
Sequence
]
=
0
)
->
np
.
ndarray
:
flagmax
=
np
.
max
(
np
.
array
(
flags
))
ndigits
=
int
(
np
.
ceil
(
np
.
log10
(
flagmax
)))
exclude
=
set
(
np
.
array
(
exclude
).
ravel
())
out
=
np
.
zeros_like
(
flags
)
for
pos
in
range
(
ndigits
):
if
pos
not
in
exclude
:
out
=
np
.
maximum
(
out
,
self
.
_getFlags
(
flags
,
pos
))
return
out
def
_getFlags
(
self
,
flags
:
pd
.
DataFrame
,
pos
:
int
)
->
np
.
ndarray
:
flags
=
self
.
_prepFlags
(
flags
)
pos
=
np
.
broadcast_to
(
np
.
atleast_1d
(
pos
),
flags
.
shape
)
ndigits
=
np
.
floor
(
np
.
log10
(
flags
)).
astype
(
np
.
int
)
idx
=
np
.
where
(
ndigits
>=
pos
)
out
=
np
.
zeros_like
(
flags
)
out
[
idx
]
=
flags
[
idx
]
//
10
**
(
ndigits
[
idx
]
-
pos
[
idx
])
%
10
return
out
def
_prepFlags
(
self
,
flags
:
ArrayLike
)
->
np
.
ndarray
:
out
=
numpyfy
(
flags
)
return
out
def
_writeFlags
(
self
,
flags
:
pd
.
DataFrame
,
values
:
Union
[
pd
.
DataFrame
,
int
],
pos
:
int
)
->
np
.
ndarray
:
flags
,
pos
,
values
=
broadcastMany
(
flags
,
pos
,
values
)
out
=
flags
.
astype
(
np
.
float64
)
# right-pad 'flags' with zeros, to assure the
# desired flag position is available
ndigits
=
np
.
floor
(
np
.
log10
(
out
)).
astype
(
np
.
int
)
idx
=
(
ndigits
<
pos
)
out
[
idx
]
*=
10
**
(
pos
[
idx
]
-
ndigits
[
idx
])
ndigits
=
np
.
log10
(
out
).
astype
(
np
.
int
)
out
[
idx
]
+=
10
**
(
ndigits
[
idx
]
-
pos
[
idx
])
*
values
[
idx
]
return
out
.
astype
(
np
.
int64
)
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