From: Ben Pfaff Date: Mon, 17 Jan 2022 06:28:32 +0000 (-0800) Subject: A few basic tests pass. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp;a=commitdiff_plain;h=948615ba8e6585d3b8b655a181ec9fdc4bbad36f A few basic tests pass. --- diff --git a/src/language/stats/ctables.c b/src/language/stats/ctables.c index af53a6b6c5..6b6b46a035 100644 --- a/src/language/stats/ctables.c +++ b/src/language/stats/ctables.c @@ -1925,7 +1925,8 @@ ctables_summary_add (union ctables_summary *s, case CTSF_LAYERPCT_SUM: case CTSF_LAYERROWPCT_SUM: case CTSF_LAYERCOLPCT_SUM: - moments1_add (s->moments, value->f, weight); + if (!var_is_value_missing (var, value)) + moments1_add (s->moments, value->f, weight); break; case CTSF_MEDIAN: @@ -2678,13 +2679,11 @@ ctables_table_output (struct ctables *ct, struct ctables_table *t) if (new_subtable) { n_levels = 0; - printf ("%s levels:", pivot_axis_type_to_string (a)); for (size_t k = 0; k < nest->n; k++) { enum ctables_vlabel vlabel = ct->vlabels[var_get_dict_index (nest->vars[k])]; if (vlabel != CTVL_NONE) { - printf (" var(%s)", var_get_name (nest->vars[k])); levels[n_levels++] = (struct ctables_level) { .type = CTL_VAR, .var_idx = k, @@ -2694,7 +2693,6 @@ ctables_table_output (struct ctables *ct, struct ctables_table *t) if (nest->scale_idx != k && (k != nest->n - 1 || t->label_axis[a] == a)) { - printf (" category(%s)", var_get_name (nest->vars[k])); levels[n_levels++] = (struct ctables_level) { .type = CTL_CATEGORY, .var_idx = k, @@ -2704,13 +2702,11 @@ ctables_table_output (struct ctables *ct, struct ctables_table *t) if (a == t->slabels_axis && a == t->summary_axis) { - printf (" summary"); levels[n_levels++] = (struct ctables_level) { .type = CTL_SUMMARY, .var_idx = SIZE_MAX, }; } - printf ("\n"); } size_t n_common = 0; diff --git a/tests/language/stats/ctables.at b/tests/language/stats/ctables.at index 72aac4bf85..e8b5981b10 100644 --- a/tests/language/stats/ctables.at +++ b/tests/language/stats/ctables.at @@ -11,4 +11,82 @@ CTABLES /TABLE=x[c] [ROWPCT.COUNT] > y[c]. CTABLES /TABLE=x[c] > y[c] [ROWPCT.COUNT]. ]]) AT_CHECK([pspp ctables.sps]) -AT_CLEANUP \ No newline at end of file +AT_CLEANUP + +AT_SETUP([CTABLES one categorical variable]) +AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .]) +AT_DATA([ctables.sps], +[[GET 'nhtsa.sav'. +CTABLES /TABLE QN1. +CTABLES /TABLE BY QN1. +CTABLES /TABLE BY BY QN1. +]]) +AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl + Custom Tables +╭────────────────────────────────────────────────────────────────────────┬─────╮ +│ │Count│ +├────────────────────────────────────────────────────────────────────────┼─────┤ +│ 1. How often do you usually drive a car or other Every day │ 4667│ +│motor vehicle? Several days a week │ 1274│ +│ Once a week or less │ 361│ +│ Only certain times a │ 130│ +│ year │ │ +│ Never │ 540│ +╰────────────────────────────────────────────────────────────────────────┴─────╯ + + Custom Tables +╭──────────────────────────────────────────────────────────────────────────────╮ +│ 1. How often do you usually drive a car or other motor vehicle? │ +├─────────┬──────────────────┬──────────────────┬────────────────────────┬─────┤ +│ │ Several days a │ Once a week or │ Only certain times a │ │ +│Every day│ week │ less │ year │Never│ +├─────────┼──────────────────┼──────────────────┼────────────────────────┼─────┤ +│ Count │ Count │ Count │ Count │Count│ +├─────────┼──────────────────┼──────────────────┼────────────────────────┼─────┤ +│ 4667│ 1274│ 361│ 130│ 540│ +╰─────────┴──────────────────┴──────────────────┴────────────────────────┴─────╯ + +Custom Tables +Every day +╭─────╮ +│Count│ +├─────┤ +│ 4667│ +╰─────╯ +]) +AT_CLEANUP + +AT_SETUP([CTABLES one scale variable]) +AT_CHECK([ln $top_srcdir/examples/nhtsa.sav . || cp $top_srcdir/examples/nhtsa.sav .]) +AT_DATA([ctables.sps], +[[GET 'nhtsa.sav'. +CTABLES /TABLE QND1[COUNT, MEAN, STDDEV, MINIMUM, MAXIMUM]. +CTABLES /TABLE BY QND1. +CTABLES /TABLE BY BY QND1. +]]) +AT_CHECK([pspp ctables.sps -O box=unicode -O width=80], [0], [dnl + Custom Tables +╭──────────────────────────┬─────┬────┬─────────────┬───────┬───────╮ +│ │Count│Mean│Std Deviation│Minimum│Maximum│ +├──────────────────────────┼─────┼────┼─────────────┼───────┼───────┤ +│D1. AGE: What is your age?│ 6930│ 48│ 19│ 16│ 86│ +╰──────────────────────────┴─────┴────┴─────────────┴───────┴───────╯ + + Custom Tables +╭──────────────────────────╮ +│D1. AGE: What is your age?│ +├──────────────────────────┤ +│ Mean │ +├──────────────────────────┤ +│ 48│ +╰──────────────────────────╯ + +Custom Tables +D1. AGE: What is your age? +╭────╮ +│Mean│ +├────┤ +│ 48│ +╰────╯ +]) +AT_CLEANUP