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
c3a22383
Commit
c3a22383
authored
4 years ago
by
leufen1
Browse files
Options
Downloads
Patches
Plain Diff
new tests implemented
parent
25db784d
Branches
Branches containing commit
Tags
Tags containing commit
4 merge requests
!192
include Develop
,
!191
Resolve "release v1.1.0"
,
!181
Resolve "REFAC: transformation setup"
,
!177
Resolve "KZ Filter creating additional dimension"
Pipeline
#50920
passed
4 years ago
Stage: test
Stage: docs
Stage: pages
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
test/test_configuration/test_defaults.py
+73
-0
73 additions, 0 deletions
test/test_configuration/test_defaults.py
test/test_statistics.py
+50
-1
50 additions, 1 deletion
test/test_statistics.py
with
123 additions
and
1 deletion
test/test_configuration/test_defaults.py
0 → 100644
+
73
−
0
View file @
c3a22383
from
mlair.configuration.defaults
import
*
class
TestGetDefaults
:
def
test_get_defaults
(
self
):
defaults
=
get_defaults
()
assert
isinstance
(
defaults
,
dict
)
assert
all
(
map
(
lambda
k
:
k
in
defaults
.
keys
(),
[
"
DEFAULT_STATIONS
"
,
"
DEFAULT_BATCH_SIZE
"
,
"
DEFAULT_PLOT_LIST
"
]))
assert
all
(
map
(
lambda
x
:
x
.
startswith
(
"
DEFAULT
"
),
defaults
.
keys
()))
class
TestAllDefaults
:
def
test_training_parameters
(
self
):
assert
DEFAULT_CREATE_NEW_MODEL
is
True
assert
DEFAULT_TRAIN_MODEL
is
True
assert
DEFAULT_FRACTION_OF_TRAINING
==
0.8
assert
DEFAULT_EXTREME_VALUES
is
None
assert
DEFAULT_EXTREMES_ON_RIGHT_TAIL_ONLY
is
False
assert
DEFAULT_PERMUTE_DATA
is
False
assert
DEFAULT_BATCH_SIZE
==
int
(
256
*
2
)
assert
DEFAULT_EPOCHS
==
20
def
test_data_handler_parameters
(
self
):
assert
DEFAULT_STATIONS
==
[
'
DEBW107
'
,
'
DEBY081
'
,
'
DEBW013
'
,
'
DEBW076
'
,
'
DEBW087
'
]
assert
DEFAULT_VAR_ALL_DICT
==
{
'
o3
'
:
'
dma8eu
'
,
'
relhum
'
:
'
average_values
'
,
'
temp
'
:
'
maximum
'
,
'
u
'
:
'
average_values
'
,
'
v
'
:
'
average_values
'
,
'
no
'
:
'
dma8eu
'
,
'
no2
'
:
'
dma8eu
'
,
'
cloudcover
'
:
'
average_values
'
,
'
pblheight
'
:
'
maximum
'
}
assert
DEFAULT_NETWORK
==
"
AIRBASE
"
assert
DEFAULT_STATION_TYPE
==
"
background
"
assert
DEFAULT_VARIABLES
==
DEFAULT_VAR_ALL_DICT
.
keys
()
assert
DEFAULT_START
==
"
1997-01-01
"
assert
DEFAULT_END
==
"
2017-12-31
"
assert
DEFAULT_WINDOW_HISTORY_SIZE
==
13
assert
DEFAULT_OVERWRITE_LOCAL_DATA
is
False
assert
isinstance
(
DEFAULT_TRANSFORMATION
,
TransformationClass
)
assert
DEFAULT_TRANSFORMATION
.
inputs
.
transform_method
==
"
standardise
"
assert
DEFAULT_TRANSFORMATION
.
targets
.
transform_method
==
"
standardise
"
assert
DEFAULT_TARGET_VAR
==
"
o3
"
assert
DEFAULT_TARGET_DIM
==
"
variables
"
assert
DEFAULT_WINDOW_LEAD_TIME
==
3
assert
DEFAULT_DIMENSIONS
==
{
"
new_index
"
:
[
"
datetime
"
,
"
Stations
"
]}
assert
DEFAULT_TIME_DIM
==
"
datetime
"
assert
DEFAULT_INTERPOLATION_METHOD
==
"
linear
"
assert
DEFAULT_INTERPOLATION_LIMIT
==
1
def
test_subset_parameters
(
self
):
assert
DEFAULT_TRAIN_START
==
"
1997-01-01
"
assert
DEFAULT_TRAIN_END
==
"
2007-12-31
"
assert
DEFAULT_TRAIN_MIN_LENGTH
==
90
assert
DEFAULT_VAL_START
==
"
2008-01-01
"
assert
DEFAULT_VAL_END
==
"
2009-12-31
"
assert
DEFAULT_VAL_MIN_LENGTH
==
90
assert
DEFAULT_TEST_START
==
"
2010-01-01
"
assert
DEFAULT_TEST_END
==
"
2017-12-31
"
assert
DEFAULT_TEST_MIN_LENGTH
==
90
assert
DEFAULT_TRAIN_VAL_MIN_LENGTH
==
180
assert
DEFAULT_USE_ALL_STATIONS_ON_ALL_DATA_SETS
is
True
def
test_hpc_parameters
(
self
):
assert
DEFAULT_HPC_HOST_LIST
==
[
"
jw
"
,
"
hdfmlc
"
]
assert
DEFAULT_HPC_LOGIN_LIST
==
[
"
ju
"
,
"
hdfmll
"
]
def
test_postprocessing_parameters
(
self
):
assert
DEFAULT_EVALUATE_BOOTSTRAPS
is
True
assert
DEFAULT_CREATE_NEW_BOOTSTRAPS
is
False
assert
DEFAULT_NUMBER_OF_BOOTSTRAPS
==
20
assert
DEFAULT_PLOT_LIST
==
[
"
PlotMonthlySummary
"
,
"
PlotStationMap
"
,
"
PlotClimatologicalSkillScore
"
,
"
PlotTimeSeries
"
,
"
PlotCompetitiveSkillScore
"
,
"
PlotBootstrapSkillScore
"
,
"
PlotConditionalQuantiles
"
,
"
PlotAvailability
"
]
This diff is collapsed.
Click to expand it.
test/test_statistics.py
+
50
−
1
View file @
c3a22383
...
@@ -3,7 +3,9 @@ import pandas as pd
...
@@ -3,7 +3,9 @@ import pandas as pd
import
pytest
import
pytest
import
xarray
as
xr
import
xarray
as
xr
from
mlair.helpers.statistics
import
standardise
,
standardise_inverse
,
standardise_apply
,
centre
,
centre_inverse
,
centre_apply
,
\
from
mlair.helpers.statistics
import
DataClass
,
TransformationClass
from
mlair.helpers.statistics
import
standardise
,
standardise_inverse
,
standardise_apply
,
centre
,
centre_inverse
,
\
centre_apply
,
\
apply_inverse_transformation
apply_inverse_transformation
lazy
=
pytest
.
lazy_fixture
lazy
=
pytest
.
lazy_fixture
...
@@ -113,3 +115,50 @@ class TestCentre:
...
@@ -113,3 +115,50 @@ class TestCentre:
data
=
centre_apply
(
data_orig
,
mean
)
data
=
centre_apply
(
data_orig
,
mean
)
mean_expected
=
np
.
array
([
2
,
-
5
,
10
])
-
np
.
array
([
2
,
10
,
3
])
mean_expected
=
np
.
array
([
2
,
-
5
,
10
])
-
np
.
array
([
2
,
10
,
3
])
assert
np
.
testing
.
assert_almost_equal
(
data
.
mean
(
dim
),
mean_expected
,
decimal
=
1
)
is
None
assert
np
.
testing
.
assert_almost_equal
(
data
.
mean
(
dim
),
mean_expected
,
decimal
=
1
)
is
None
class
TestDataClass
:
def
test_init
(
self
):
dc
=
DataClass
()
assert
all
([
obj
is
None
for
obj
in
[
dc
.
data
,
dc
.
mean
,
dc
.
std
,
dc
.
max
,
dc
.
min
,
dc
.
transform_method
,
dc
.
_method
]])
def
test_init_values
(
self
):
dc
=
DataClass
(
data
=
12
,
mean
=
2
,
std
=
"
test
"
,
max
=
23.4
,
min
=
np
.
array
([
3
]),
transform_method
=
"
f
"
)
assert
dc
.
data
==
12
assert
dc
.
mean
==
2
assert
dc
.
std
==
"
test
"
assert
dc
.
max
==
23.4
assert
np
.
testing
.
assert_array_equal
(
dc
.
min
,
np
.
array
([
3
]))
is
None
assert
dc
.
transform_method
==
"
f
"
assert
dc
.
_method
is
None
def
test_as_dict
(
self
):
dc
=
DataClass
(
std
=
23
)
dc
.
_method
=
"
f(x)
"
assert
dc
.
as_dict
()
==
{
"
data
"
:
None
,
"
mean
"
:
None
,
"
std
"
:
23
,
"
max
"
:
None
,
"
min
"
:
None
,
"
transform_method
"
:
None
}
class
TestTransformationClass
:
def
test_init
(
self
):
tc
=
TransformationClass
()
assert
hasattr
(
tc
,
"
inputs
"
)
assert
isinstance
(
tc
.
inputs
,
DataClass
)
assert
hasattr
(
tc
,
"
targets
"
)
assert
isinstance
(
tc
.
targets
,
DataClass
)
assert
tc
.
inputs
.
mean
is
None
assert
tc
.
targets
.
std
is
None
def
test_init_values
(
self
):
tc
=
TransformationClass
(
inputs_mean
=
1
,
inputs_std
=
2
,
inputs_method
=
"
f
"
,
targets_mean
=
3
,
targets_std
=
4
,
targets_method
=
"
g
"
)
assert
tc
.
inputs
.
mean
==
1
assert
tc
.
inputs
.
std
==
2
assert
tc
.
inputs
.
transform_method
==
"
f
"
assert
tc
.
inputs
.
max
is
None
assert
tc
.
targets
.
mean
==
3
assert
tc
.
targets
.
std
==
4
assert
tc
.
targets
.
transform_method
==
"
g
"
assert
tc
.
inputs
.
min
is
None
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