From: Ben Pfaff Date: Tue, 28 Jan 2025 22:22:51 +0000 (-0800) Subject: QUICK CLUSTER: Use fixed format for cluster centers. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2284baf7ab2097e7655a376ef7a6f9146a18f952;p=pspp QUICK CLUSTER: Use fixed format for cluster centers. This command used the variables' own formats for their centers. This was a bad idea for at least two reasons. First, the variables might have a format that does not show any decimal places, but clusters wouldn't ordinarily have integer centers, so this is confusing. Second, if a cluster center happens to have a value label, it could be shown instead, which is even more confusing. This fixes the problem by using a fixed format instead. Thanks to Andreas Hammer for reporting the problem. --- diff --git a/src/language/commands/quick-cluster.c b/src/language/commands/quick-cluster.c index 128130afe3..cb58170069 100644 --- a/src/language/commands/quick-cluster.c +++ b/src/language/commands/quick-cluster.c @@ -549,9 +549,7 @@ quick_cluster_show_centers (struct Kmeans *kmeans, bool initial, const struct qc for (size_t j = 0; j < qc->n_vars; j++) { double x = gsl_matrix_get (matrix, kmeans->group_order->data[i], j); - union value v = { .f = x }; - pivot_table_put2 (table, i, j, - pivot_value_new_var_value (qc->vars[j], &v)); + pivot_table_put2 (table, i, j, pivot_value_new_number (x)); } pivot_table_submit (table); diff --git a/tests/language/commands/quick-cluster.at b/tests/language/commands/quick-cluster.at index 12f4b2ac43..f467d1d6b2 100644 --- a/tests/language/commands/quick-cluster.at +++ b/tests/language/commands/quick-cluster.at @@ -350,14 +350,14 @@ AT_CHECK([pspp -O format=csv quick-cluster.sps], [0], [dnl Table: Initial Cluster Centers ,Cluster,, ,1,2,3 -x,-11,-12,11 -y,-12,11,11 +x,-10.80,-11.65,11.10 +y,-11.76,10.81,10.91 Table: Final Cluster Centers ,Cluster,, ,1,2,3 -x,-10,-10,10 -y,-10,10,10 +x,-10.22,-10.14,10.28 +y,-10.01,10.22,9.89 Table: Number of Cases in each Cluster ,,Count