diff --git a/src/cluster.jl b/src/cluster.jl index 99c132b..38d57e1 100644 --- a/src/cluster.jl +++ b/src/cluster.jl @@ -226,7 +226,7 @@ function find_period_weights( incomplete_period_weight = nothing else complete_period_weight = 1.0 - incomplete_period_weight = last_period_duration / period_duration + incomplete_period_weight = 1.0 end return complete_period_weight, incomplete_period_weight end diff --git a/test/test-cluster.jl b/test/test-cluster.jl index b7f1aef..913de57 100644 --- a/test/test-cluster.jl +++ b/test/test-cluster.jl @@ -122,7 +122,7 @@ end clustering_result = find_representative_periods(clustering_data, 2; method = :k_means, init = :kmcen) - clustering_result.weight_matrix == [1.0 0.0; 0.0 0.5] + clustering_result.weight_matrix == [1.0 0.0; 0.0 1.0] end @test begin @@ -172,7 +172,7 @@ end clustering_result = find_representative_periods(clustering_data, 2; method = :k_medoids, init = :kmcen) - clustering_result.weight_matrix == [1.0 0.0; 0.0 0.5] + clustering_result.weight_matrix == [1.0 0.0; 0.0 1.0] end @test begin diff --git a/test/test-weight-fitting.jl b/test/test-weight-fitting.jl index 80958aa..8ace43f 100644 --- a/test/test-weight-fitting.jl +++ b/test/test-weight-fitting.jl @@ -49,7 +49,7 @@ end init = :kmcen, ) TulipaClustering.fit_rep_period_weights!(clustering_result; weight_type = :convex, niters = 5) - sum(clustering_result.weight_matrix) ≈ 365 / 7 && + sum(clustering_result.weight_matrix) ≈ round(365 / 7, RoundUp) && all(sum(clustering_result.weight_matrix[1:(end - 1), :], dims = 2) .≈ 1.0) end end