Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
MLAir
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
machine-learning
MLAir
Commits
f0046284
Commit
f0046284
authored
4 years ago
by
leufen1
Browse files
Options
Downloads
Patches
Plain Diff
tests for update_kwargs method
parent
2a3b496a
Branches
Branches containing commit
Tags
Tags containing commit
3 merge requests
!226
Develop
,
!225
Resolve "release v1.2.0"
,
!208
Resolve "mixed sampling decouple interpolation"
Pipeline
#54835
passed with warnings
4 years ago
Stage: test
Stage: docs
Stage: pages
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/test_data_handler/test_data_handler_mixed_sampling.py
+130
-0
130 additions, 0 deletions
test/test_data_handler/test_data_handler_mixed_sampling.py
with
130 additions
and
0 deletions
test/test_data_handler/test_data_handler_mixed_sampling.py
0 → 100644
+
130
−
0
View file @
f0046284
__author__
=
'
Lukas Leufen
'
__date__
=
'
2020-12-10
'
from
mlair.data_handler.data_handler_mixed_sampling
import
DataHandlerMixedSampling
,
\
DataHandlerMixedSamplingSingleStation
,
DataHandlerMixedSamplingWithFilter
,
\
DataHandlerMixedSamplingWithFilterSingleStation
,
DataHandlerSeparationOfScales
,
\
DataHandlerSeparationOfScalesSingleStation
from
mlair.data_handler.data_handler_kz_filter
import
DataHandlerKzFilterSingleStation
from
mlair.data_handler.data_handler_single_station
import
DataHandlerSingleStation
from
mlair.helpers
import
remove_items
from
mlair.configuration.defaults
import
DEFAULT_INTERPOLATION_METHOD
import
pytest
import
mock
class
TestDataHandlerMixedSampling
:
def
test_data_handler
(
self
):
obj
=
object
.
__new__
(
DataHandlerMixedSampling
)
assert
obj
.
data_handler
.
__qualname__
==
DataHandlerMixedSamplingSingleStation
.
__qualname__
def
test_data_handler_transformation
(
self
):
obj
=
object
.
__new__
(
DataHandlerMixedSampling
)
assert
obj
.
data_handler_transformation
.
__qualname__
==
DataHandlerMixedSamplingSingleStation
.
__qualname__
def
test_requirements
(
self
):
obj
=
object
.
__new__
(
DataHandlerMixedSampling
)
req
=
object
.
__new__
(
DataHandlerSingleStation
)
assert
sorted
(
obj
.
_requirements
)
==
sorted
(
remove_items
(
req
.
requirements
(),
"
station
"
))
class
TestDataHandlerMixedSamplingSingleStation
:
def
test_requirements
(
self
):
obj
=
object
.
__new__
(
DataHandlerMixedSamplingSingleStation
)
req
=
object
.
__new__
(
DataHandlerSingleStation
)
assert
sorted
(
obj
.
_requirements
)
==
sorted
(
remove_items
(
req
.
requirements
(),
"
station
"
))
@mock.patch
(
"
mlair.data_handler.data_handler_mixed_sampling.DataHandlerMixedSamplingSingleStation.setup_samples
"
)
def
test_init
(
self
,
mock_super_init
):
obj
=
DataHandlerMixedSamplingSingleStation
(
"
first_arg
"
,
"
second
"
,
{},
test
=
23
,
sampling
=
"
hourly
"
,
interpolation_limit
=
(
1
,
10
))
assert
obj
.
sampling
==
(
"
hourly
"
,
"
hourly
"
)
assert
obj
.
interpolation_limit
==
(
1
,
10
)
assert
obj
.
interpolation_method
==
(
DEFAULT_INTERPOLATION_METHOD
,
DEFAULT_INTERPOLATION_METHOD
)
@pytest.fixture
def
kwargs_dict
(
self
):
return
{
"
test1
"
:
2
,
"
param_2
"
:
"
string
"
,
"
another
"
:
(
10
,
2
)}
def
test_update_kwargs_single_to_tuple
(
self
,
kwargs_dict
):
obj
=
object
.
__new__
(
DataHandlerMixedSamplingSingleStation
)
obj
.
update_kwargs
(
"
test1
"
,
"
23
"
,
kwargs_dict
)
assert
kwargs_dict
[
"
test1
"
]
==
(
2
,
2
)
obj
.
update_kwargs
(
"
param_2
"
,
"
23
"
,
kwargs_dict
)
assert
kwargs_dict
[
"
param_2
"
]
==
(
"
string
"
,
"
string
"
)
def
test_update_kwargs_tuple
(
self
,
kwargs_dict
):
obj
=
object
.
__new__
(
DataHandlerMixedSamplingSingleStation
)
obj
.
update_kwargs
(
"
another
"
,
"
23
"
,
kwargs_dict
)
assert
kwargs_dict
[
"
another
"
]
==
(
10
,
2
)
def
test_update_kwargs_default
(
self
,
kwargs_dict
):
obj
=
object
.
__new__
(
DataHandlerMixedSamplingSingleStation
)
obj
.
update_kwargs
(
"
not_existing
"
,
"
23
"
,
kwargs_dict
)
assert
kwargs_dict
[
"
not_existing
"
]
==
(
"
23
"
,
"
23
"
)
obj
.
update_kwargs
(
"
also_new
"
,
(
4
,
2
),
kwargs_dict
)
assert
kwargs_dict
[
"
also_new
"
]
==
(
4
,
2
)
def
test_update_kwargs_assert_failure
(
self
,
kwargs_dict
):
obj
=
object
.
__new__
(
DataHandlerMixedSamplingSingleStation
)
with
pytest
.
raises
(
AssertionError
):
obj
.
update_kwargs
(
"
error_too_long
"
,
(
1
,
2
,
3
),
kwargs_dict
)
def
test_setup_samples
(
self
):
pass
def
test_load_and_interpolate
(
self
):
pass
def
test_set_inputs_and_targets
(
self
):
pass
def
test_setup_data_path
(
self
):
pass
class
TestDataHandlerMixedSamplingWithFilter
:
def
test_data_handler
(
self
):
obj
=
object
.
__new__
(
DataHandlerMixedSamplingWithFilter
)
assert
obj
.
data_handler
.
__qualname__
==
DataHandlerMixedSamplingWithFilterSingleStation
.
__qualname__
def
test_data_handler_transformation
(
self
):
obj
=
object
.
__new__
(
DataHandlerMixedSamplingWithFilter
)
assert
obj
.
data_handler_transformation
.
__qualname__
==
DataHandlerMixedSamplingWithFilterSingleStation
.
__qualname__
def
test_requirements
(
self
):
obj
=
object
.
__new__
(
DataHandlerMixedSamplingWithFilter
)
req1
=
object
.
__new__
(
DataHandlerMixedSamplingSingleStation
)
req2
=
object
.
__new__
(
DataHandlerKzFilterSingleStation
)
req
=
list
(
set
(
req1
.
requirements
()
+
req2
.
requirements
()))
assert
sorted
(
obj
.
_requirements
)
==
sorted
(
remove_items
(
req
,
"
station
"
))
class
TestDataHandlerMixedSamplingWithFilterSingleStation
:
pass
class
TestDataHandlerSeparationOfScales
:
def
test_data_handler
(
self
):
obj
=
object
.
__new__
(
DataHandlerSeparationOfScales
)
assert
obj
.
data_handler
.
__qualname__
==
DataHandlerSeparationOfScalesSingleStation
.
__qualname__
def
test_data_handler_transformation
(
self
):
obj
=
object
.
__new__
(
DataHandlerSeparationOfScales
)
assert
obj
.
data_handler_transformation
.
__qualname__
==
DataHandlerSeparationOfScalesSingleStation
.
__qualname__
def
test_requirements
(
self
):
obj
=
object
.
__new__
(
DataHandlerMixedSamplingWithFilter
)
req1
=
object
.
__new__
(
DataHandlerMixedSamplingSingleStation
)
req2
=
object
.
__new__
(
DataHandlerKzFilterSingleStation
)
req
=
list
(
set
(
req1
.
requirements
()
+
req2
.
requirements
()))
assert
sorted
(
obj
.
_requirements
)
==
sorted
(
remove_items
(
req
,
"
station
"
))
class
TestDataHandlerSeparationOfScalesSingleStation
:
pass
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