From: Ben Pfaff Date: Sat, 27 Aug 2022 21:08:05 +0000 (-0700) Subject: refactoring X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=86e9ee9536888f2d76f5ee2c3354c88d97233bc1 refactoring --- diff --git a/src/language/stats/ctables.c b/src/language/stats/ctables.c index 68d3e852ba..19c1bb84cc 100644 --- a/src/language/stats/ctables.c +++ b/src/language/stats/ctables.c @@ -1224,7 +1224,6 @@ add_summary_spec (struct ctables_axis *axis, static struct ctables_axis *ctables_axis_parse_stack ( struct ctables_axis_parse_ctx *); - static struct ctables_axis * ctables_axis_parse_primary (struct ctables_axis_parse_ctx *ctx) { @@ -2663,50 +2662,39 @@ ctables_summary_add (union ctables_summary *s, double weight) { /* To determine whether a case is included in a given table for a particular - kind of summary, consider the following charts for each variable in the - table. Only if "yes" appears for every variable for the summary is the - case counted. + kind of summary, consider the following charts for the variable being + summarized. Only if "yes" appears is the case counted. - Categorical variables: VALIDN COUNT TOTALN + Categorical variables: VALIDN other TOTALN Valid values in included categories yes yes yes Missing values in included categories --- yes yes Missing values in excluded categories --- --- yes Valid values in excluded categories --- --- --- - Scale variables: VALIDN COUNT TOTALN + Scale variables: VALIDN other TOTALN Valid value yes yes yes Missing value --- yes yes Missing values include both user- and system-missing. (The system-missing value is always in an excluded category.) + + One way to interpret the above table is that scale variables are like + categorical variables in which all values are in included categories. */ switch (ss->function) { case CTSF_TOTALN: - s->count += weight; - break; - case CTSF_areaPCT_TOTALN: s->count += weight; break; case CTSF_COUNT: - if (is_scale || is_included) - s->count += weight; - break; - case CTSF_areaPCT_COUNT: - if (is_scale || is_included) + if (is_included) s->count += weight; break; case CTSF_VALIDN: - if (is_scale - ? !is_scale_missing - : !is_missing) - s->count += weight; - break; - case CTSF_areaPCT_VALIDN: if (is_scale ? !is_scale_missing @@ -3297,11 +3285,12 @@ ctables_cell_add__ (struct ctables_section *s, const struct ccase *c, const struct ctables_summary_spec_set *specs = &ss->specs[cell->sv]; const union value *value = case_data (c, specs->var); bool is_missing = var_is_value_missing (specs->var, value); - bool scale_missing = specs->is_scale && (is_missing || is_listwise_missing (specs, c)); + bool is_scale_missing + = specs->is_scale && (is_missing || is_listwise_missing (specs, c)); for (size_t i = 0; i < specs->n; i++) ctables_summary_add (&cell->summaries[i], &specs->specs[i], value, - specs->is_scale, scale_missing, is_missing, + specs->is_scale, is_scale_missing, is_missing, is_included, weight[specs->specs[i].weighting]); for (enum ctables_area_type at = 0; at < N_CTATS; at++) if (!(cell->omit_areas && (1u << at))) @@ -3315,7 +3304,7 @@ ctables_cell_add__ (struct ctables_section *s, const struct ccase *c, { add_weight (a->valid, weight); - if (!scale_missing) + if (!is_scale_missing) for (size_t i = 0; i < s->table->n_sum_vars; i++) { const struct variable *var = s->table->sum_vars[i];