Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
iObs
WP2
Task 2.3
netatmoqc
Commits
9c7271f1
Commit
9c7271f1
authored
Jul 12, 2021
by
Paulo Medeiros
Browse files
Fix test_metrics.py
parent
7f378cf4
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/test_metrics.py
View file @
9c7271f1
...
...
@@ -2,12 +2,14 @@
"""Tests concerning the code's custom metrics."""
import
logging
import
time
from
pathlib
import
Path
import
numpy
as
np
import
pandas
as
pd
import
pytest
from
sklearn.metrics.pairwise
import
haversine_distances
from
netatmoqc.config_parser
import
ParsedConfig
from
netatmoqc.metrics
import
calc_distance_matrix
logger
=
logging
.
getLogger
(
__name__
)
...
...
@@ -34,14 +36,20 @@ class TestsCustomMetrics:
some_obs
=
np
.
zeros
(
n_pts
),
)
)
weights
=
np
.
array
([
1.0
,
0.0
])
# Prepare a mock config
fpath
=
Path
(
__file__
).
resolve
().
parent
/
"test_config.toml"
config
=
ParsedConfig
(
fpath
)
config
.
general
.
custom_metrics_method
=
"haversine"
config
.
general
.
clustering_method
=
"hdbscan"
config
.
clustering_method
.
hdbscan
.
obs_weights
=
{
"some_obs"
:
0.0
}
config
.
general
.
custom_metrics_optimize_mode
=
"speed"
config
.
general
.
unclusterable_data_columns
=
[]
logger
.
info
(
"Calculating %dx%d distance matrix:"
,
n_pts
,
n_pts
)
logger
.
info
(
"(a) With our code's metrics"
)
start
=
time
.
time
()
dist_mat1
=
np
.
asarray
(
calc_distance_matrix
(
df
,
weights
=
weights
,
optimize_mode
=
"speed"
)
)
dist_mat1
=
np
.
asarray
(
calc_distance_matrix
(
df
,
config
=
config
))
logger
.
info
(
"Done in %.2fs"
,
time
.
time
()
-
start
)
logger
.
info
(
"(b) With sklearn metrics"
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment