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
1f3cc3a6
Commit
1f3cc3a6
authored
2 years ago
by
Peter Lünenschloß
Browse files
Options
Downloads
Patches
Plain Diff
resample signature cleanup
parent
3cbbfdb0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
3 merge requests
!685
Release 2.4
,
!684
Release 2.4
,
!664
resample signature cleanup
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CHANGELOG.md
+2
-1
2 additions, 1 deletion
CHANGELOG.md
saqc/funcs/resampling.py
+5
-43
5 additions, 43 deletions
saqc/funcs/resampling.py
saqc/lib/tools.py
+0
-32
0 additions, 32 deletions
saqc/lib/tools.py
with
7 additions
and
76 deletions
CHANGELOG.md
+
2
−
1
View file @
1f3cc3a6
...
...
@@ -16,9 +16,10 @@ SPDX-License-Identifier: GPL-3.0-or-later
-
Deprecate
`interpolate`
,
`linear`
and
`shift`
in favor of
`align`
-
Depreacte
`roll`
in favor of
`rolling`
-
Rename
`interplateInvalid`
to
`interpolate`
-
Rename
`interpolateIndex`
to
`align`
-
Rename
`interpolateIndex`
to
`align`
### Removed
-
Parameter
`limit`
from
`align`
-
Parameter
`max_na_group_flags`
,
`max_na_flags`
,
`flag_func`
,
`freq_check`
removed from
`resample`
### Fixed
-
`func`
arguments in text configurations were not parsed correctly
-
fail on duplicated arguments to test methods
...
...
This diff is collapsed.
Click to expand it.
saqc/funcs/resampling.py
+
5
−
43
View file @
1f3cc3a6
...
...
@@ -18,7 +18,7 @@ from typing_extensions import Literal
from
saqc.constants
import
UNFLAGGED
from
saqc.core
import
register
from
saqc.funcs.interpolation
import
_SUPPORTED_METHODS
from
saqc.lib.tools
import
evalFreqStr
,
filterKwargs
,
getFreqDelta
,
isflagged
from
saqc.lib.tools
import
filterKwargs
,
getFreqDelta
,
isflagged
from
saqc.lib.ts_operators
import
aggregate2Freq
,
shift2Freq
if
TYPE_CHECKING
:
...
...
@@ -78,7 +78,6 @@ class ResamplingMixin:
field
:
str
,
freq
:
str
,
method
:
Literal
[
"
fshift
"
,
"
bshift
"
,
"
nshift
"
]
=
"
nshift
"
,
freq_check
:
Optional
[
Literal
[
"
check
"
,
"
auto
"
]]
=
None
,
**
kwargs
,
)
->
"
SaQC
"
:
"""
...
...
@@ -99,11 +98,6 @@ class ResamplingMixin:
*
'
bshift
'
: shift grid points to the first succeeding time stamp (if any)
*
'
fshift
'
: shift grid points to the last preceeding time stamp (if any)
freq_check : {None,
'
check
'
,
'
auto
'
}, default None
* ``None`` : do not validate the ``freq`` string.
*
'
check
'
: check ``freq`` against an frequency estimation, produces a warning in case of miss matches.
*
'
auto
'
: estimate frequency, `freq` is ignored.
Returns
-------
saqc.SaQC
...
...
@@ -116,7 +110,7 @@ class ResamplingMixin:
"""
,
DeprecationWarning
,
)
freq
=
evalFreqStr
(
freq
,
freq_check
,
self
.
_data
[
field
].
index
)
return
self
.
align
(
field
=
field
,
freq
=
freq
,
method
=
method
,
**
kwargs
)
@register
(
mask
=
[
"
field
"
],
demask
=
[],
squeeze
=
[])
...
...
@@ -128,10 +122,6 @@ class ResamplingMixin:
method
:
Literal
[
"
fagg
"
,
"
bagg
"
,
"
nagg
"
]
=
"
bagg
"
,
maxna
:
Optional
[
int
]
=
None
,
maxna_group
:
Optional
[
int
]
=
None
,
maxna_flags
:
Optional
[
int
]
=
None
,
# TODO: still a case ??
maxna_group_flags
:
Optional
[
int
]
=
None
,
flag_func
:
Callable
[[
pd
.
Series
],
float
]
=
max
,
freq_check
:
Optional
[
Literal
[
"
check
"
,
"
auto
"
]]
=
None
,
**
kwargs
,
)
->
"
SaQC
"
:
"""
...
...
@@ -180,28 +170,6 @@ class ResamplingMixin:
maxna_group : {None, int}, default None
Same as `maxna` but for consecutive NaNs.
maxna_flags : {None, int}, default None
Same as `max_invalid`, only applying for the flags. The flag regarded
as
"
invalid
"
value, is the one passed to empty_intervals_flag (
default=``BAD``). Also this is the flag assigned to invalid/empty intervals.
maxna_group_flags : {None, int}, default None
Same as `maxna_flags`, only applying onto flags. The flag regarded as
"
invalid
"
value, is the one passed to empty_intervals_flag. Also this is the
flag assigned to invalid/empty intervals.
flag_func : Callable, default: max
The function you want to aggregate the flags with. It should be capable of
operating on the flags dtype (usually ordered categorical).
freq_check : {None,
'
check
'
,
'
auto
'
}, default None
* ``None``: do not validate frequency-string passed to `freq`
* ``
'
check
'
``: estimate frequency and log a warning if estimate miss matchs
frequency string passed to
'
freq
'
, or if no uniform sampling rate could be
estimated
* ``
'
auto
'
``: estimate frequency and use estimate. (Ignores `freq` parameter.)
Returns
-------
saqc.SaQC
...
...
@@ -213,8 +181,6 @@ class ResamplingMixin:
# see for #GL-374
datcol
=
pd
.
Series
(
index
=
pd
.
DatetimeIndex
([]),
dtype
=
datcol
.
dtype
)
freq
=
evalFreqStr
(
freq
,
freq_check
,
datcol
.
index
)
datcol
=
aggregate2Freq
(
datcol
,
method
,
...
...
@@ -228,10 +194,10 @@ class ResamplingMixin:
kws
=
dict
(
method
=
method
,
freq
=
freq
,
agg_func
=
flag_func
,
agg_func
=
max
,
fill_value
=
np
.
nan
,
max_invalid_total
=
maxna
_flags
,
max_invalid_consec
=
maxna_group
_flags
,
max_invalid_total
=
maxna
,
max_invalid_consec
=
maxna_group
,
)
history
=
self
.
_flags
.
history
[
field
].
apply
(
...
...
@@ -248,10 +214,6 @@ class ResamplingMixin:
"
method
"
:
method
,
"
maxna
"
:
maxna
,
"
maxna_group
"
:
maxna_group
,
"
maxna_flags
"
:
maxna_flags
,
"
maxna_group_flags
"
:
maxna_group_flags
,
"
flag_func
"
:
flag_func
,
"
freq_check
"
:
freq_check
,
**
kwargs
,
},
}
...
...
This diff is collapsed.
Click to expand it.
saqc/lib/tools.py
+
0
−
32
View file @
1f3cc3a6
...
...
@@ -292,38 +292,6 @@ def estimateFrequency(
return
str
(
int
(
gcd_freq
))
+
"
min
"
,
[
str
(
int
(
i
))
+
"
min
"
for
i
in
freqs
]
def
evalFreqStr
(
freq
,
check
,
index
):
if
check
in
[
"
check
"
,
"
auto
"
]:
f_passed
=
freq
freq
=
index
.
inferred_freq
freqs
=
[
freq
]
if
freq
is
None
:
freq
,
freqs
=
estimateFrequency
(
index
)
if
freq
is
None
:
warnings
.
warn
(
"
Sampling rate could not be estimated.
"
)
if
len
(
freqs
)
>
1
:
warnings
.
warn
(
f
"
Sampling rate seems to be not uniform!.
"
f
"
Detected:
{
freqs
}
"
)
if
check
==
"
check
"
:
f_passed_seconds
=
pd
.
Timedelta
(
f_passed
).
total_seconds
()
freq_seconds
=
pd
.
Timedelta
(
freq
).
total_seconds
()
if
f_passed_seconds
!=
freq_seconds
:
warnings
.
warn
(
f
"
Sampling rate estimate (
{
freq
}
) missmatches passed frequency (
{
f_passed
}
).
"
)
elif
check
==
"
auto
"
:
if
freq
is
None
:
raise
ValueError
(
"
Frequency estimation for non-empty series failed with no fall back frequency passed.
"
)
f_passed
=
freq
else
:
f_passed
=
freq
return
f_passed
def
detectDeviants
(
data
,
metric
,
...
...
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