X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;ds=inline;f=src%2Fmath%2Fcategoricals.c;h=8bd6683e2c94ab5d92dbe840fef7737adf367fdf;hb=0054d7bf45fb09a455698d1a180db93055f49dba;hp=b621d982931c72c0eadbb04e420d943e10a5cded;hpb=0df9cdd3df66caf4353128feff3008289cda8115;p=pspp diff --git a/src/math/categoricals.c b/src/math/categoricals.c index b621d98293..8bd6683e2c 100644 --- a/src/math/categoricals.c +++ b/src/math/categoricals.c @@ -196,6 +196,31 @@ struct categoricals const struct payload *payload; }; + +bool +categoricals_isbalanced (const struct categoricals *cat) +{ + int i; + + for (i = 0 ; i < cat->n_iap; ++i) + { + int v; + const struct interact_params *iap = &cat->iap[i]; + + double oval = -1.0; + for (v = 0; v < hmap_count (&iap->ivmap); ++v) + { + const struct interaction_value *iv = iap->reverse_interaction_value_map[v]; + if (oval == -1.0) + oval = iv->cc; + if (oval != iv->cc) + return false; + } + } + return true; +} + + static void categoricals_dump (const struct categoricals *cat) { @@ -388,6 +413,7 @@ categoricals_update (struct categoricals *cat, const struct ccase *c) return; weight = cat->wv ? case_data (c, cat->wv)->f : 1.0; + weight = var_force_valid_weight (cat->wv, weight, NULL); assert (NULL == cat->reverse_variable_map_short); assert (NULL == cat->reverse_variable_map_long); @@ -446,10 +472,8 @@ categoricals_update (struct categoricals *cat, const struct ccase *c) if (cat->payload) { - double weight = cat->wv ? case_data (c, cat->wv)->f : 1.0; cat->payload->update (cat->aux1, cat->aux2, node->user_data, c, weight); } - } }