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
Merge requests
!225
Resolve "release v1.2.0"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "release v1.2.0"
release_v1.2.0
into
master
Overview
0
Commits
96
Pipelines
3
Changes
1
Merged
Ghost User
requested to merge
release_v1.2.0
into
master
4 years ago
Overview
0
Commits
96
Pipelines
3
Changes
1
Expand
Closes
#257 (closed)
Edited
4 years ago
by
Ghost User
0
0
Merge request reports
Viewing commit
f0046284
Prev
Next
Show latest version
1 file
+
130
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
f0046284
tests for update_kwargs method
· f0046284
leufen1
authored
4 years ago
test/test_data_handler/test_data_handler_mixed_sampling.py
0 → 100644
+
130
−
0
Options
__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
Loading