CTABLES: Refine treatment for applying a summary to nested variables.
authorBen Pfaff <blp@cs.stanford.edu>
Sun, 28 May 2023 16:27:33 +0000 (09:27 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 28 May 2023 16:27:33 +0000 (09:27 -0700)
In the previous commit, applying a summary to a nest operator caused an
error, which I assumed was the correct behvior.  This commit changes it
to apply the summary to the inner variable.

Thanks to Matthias Faeth for reporting the correct behavior.

src/language/commands/ctables.c
tests/language/commands/ctables.at

index fc429e1f36aab879fc51d0be568b4b229aec785e..996ada88873ce1de379180973f7b7910e11fa2ce 100644 (file)
@@ -1202,12 +1202,9 @@ add_summary_spec (struct ctables_axis *axis,
       return true;
     }
   else if (axis->op == CTAO_NEST)
-    {
-      msg_at (SE, loc, _("Summary functions may not be applied to the nest "
-                         "operator '>'."));
-      msg_at (SN, axis->loc, _("This is where the nest operator was used."));
-      return false;
-    }
+    return add_summary_spec (axis->subs[1], function, weighting, area,
+                             percentile, label, format, is_ctables_format,
+                             loc, sv);
   else
     {
       assert (axis->op == CTAO_STACK);
index 9dd5c0e5e83de00ec96a3a6d0fe28457a92cd9d0..52bdb2ded15d6bfe7e7536d70185fd3834bb8e22 100644 (file)
@@ -741,8 +741,6 @@ CTABLES /TABLE qn113 [COUNT.UCL].
 CTABLES /TABLE qn1 /CATEGORIES **.
 
 CTABLES /TITLES.
-
-CTABLES /TABLE (qn1 > qn113) [COUNT].
 ]])
 AT_CHECK([pspp ctables.sps -O box=unicode -O width=120], [1],
 [[ctables.sps:2.76-2.78: error: CTABLES: Computed category &pc references a category not included in the category list.
@@ -890,14 +888,6 @@ PCOMPUTE, PPROPERTIES, WEIGHT, HIDESMALLCOUNTS, TABLE.
 ctables.sps:36.10-36.15: note: CTABLES: TABLE must appear before this subcommand.
    36 | CTABLES /TITLES.
       |          ^~~~~~
-
-ctables.sps:38.31-38.35: error: CTABLES: Summary functions may not be applied to the nest operator '>'.
-   38 | CTABLES /TABLE (qn1 > qn113) [COUNT].
-      |                               ^~~~~
-
-ctables.sps:38.17-38.27: note: CTABLES: This is where the nest operator was used.
-   38 | CTABLES /TABLE (qn1 > qn113) [COUNT].
-      |                 ^~~~~~~~~~~
 ]])
 AT_CLEANUP
 
@@ -1474,7 +1464,7 @@ AT_KEYWORDS([nest nested])
 AT_CHECK([ln $top_srcdir/tests/language/commands/nhtsa.sav . || cp $top_srcdir/tests/language/commands/nhtsa.sav .])
 AT_DATA([ctables.sps],
 [[GET 'nhtsa.sav'.
-CTABLES /TABLE (qn105ba + qn105bb + qn105bc + qn105bd) > qns3a [COUNT, TABLEPCT PCT8.0]
+CTABLES /TABLE ((qn105ba + qn105bb + qn105bc + qn105bd) > qns3a) [COUNT, TABLEPCT PCT8.0]
   /CATEGORIES VARIABLES=qns3a TOTAL=YES.
 CTABLES /TABLE qns3a > (qn105ba + qn105bb + qn105bc + qn105bd) [TABLEPCT PCT8.0]
   /CATEGORIES VARIABLES=qns3a TOTAL=YES