Commit 9c7271f1 authored by Paulo Medeiros's avatar Paulo Medeiros
Browse files

Fix test_metrics.py

parent 7f378cf4
......@@ -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")
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment