work
authorBen Pfaff <blp@cs.stanford.edu>
Mon, 11 Aug 2025 20:32:57 +0000 (13:32 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Mon, 11 Aug 2025 20:32:57 +0000 (13:32 -0700)
rust/pspp/src/dictionary.rs
rust/pspp/src/sys/testdata/variable_sets.expected
rust/pspp/src/sys/testdata/variable_sets_unknown_variable.expected

index 4798f557954bd40cbdc95d0a4520bd43e142c183..a1f35907fb5b0616ef2cfbe412f1911658ddf011 100644 (file)
@@ -897,17 +897,21 @@ impl<'a> OutputVariableSets<'a> {
             }
             variable_sets.push(group);
         }
-        let mut pt = PivotTable::new([
-            (Axis3::Y, Dimension::new(variable_sets)),
-            (
-                Axis3::X,
-                Dimension::new(Group::new("Attributes").with("Variable")),
+        Some(
+            PivotTable::new([
+                (Axis3::Y, Dimension::new(variable_sets)),
+                (
+                    Axis3::X,
+                    Dimension::new(Group::new("Attributes").with("Variable")),
+                ),
+            ])
+            .with_title("Variable Sets")
+            .with_data(
+                data.into_iter()
+                    .enumerate()
+                    .map(|(row, datum)| ([row, 0], datum)),
             ),
-        ]);
-        for (row, datum) in data.into_iter().enumerate() {
-            pt.insert(&[row, 0], datum);
-        }
-        Some(pt)
+        )
     }
 }
 
@@ -1034,7 +1038,8 @@ impl<'a> OutputAttributes<'a> {
         let mut pt = PivotTable::new([
             (Axis3::X, Dimension::new(values)),
             (Axis3::Y, Dimension::new(variables)),
-        ]).with_title("Data File and Variable Attributes");
+        ])
+        .with_title("Data File and Variable Attributes");
         for (row, datum) in data.into_iter().enumerate() {
             pt.insert(&[0, row], datum);
         }
index f257f41e7ef1410600d6d80b3403905437e0f1dd..4832fda1797c8f6713eee37b374d7faefaee1088 100644 (file)
@@ -29,6 +29,7 @@
 │j │      10│     │Nominal          │Input│    4│Left     │A4          │A4          │              │
 ╰──┴────────┴─────┴─────────────────┴─────┴─────┴─────────┴────────────┴────────────┴──────────────╯
 
+              Variable Sets
 ╭─────────────────────────────┬────────╮
 │Variable Set and Position    │Variable│
 ├─────────────────────────────┼────────┤
index 1a86dade444679eb61f6a4de43e05f8d10b40e12..48f024822ed12274e4407adf922eeaca98b483d6 100644 (file)
@@ -33,6 +33,7 @@ Variable set "vs2" includes unknown variable foo.
 │j │      10│     │Nominal          │Input│    4│Left     │A4          │A4          │              │
 ╰──┴────────┴─────┴─────────────────┴─────┴─────┴─────────┴────────────┴────────────┴──────────────╯
 
+             Variable Sets
 ╭───────────────────────────┬────────╮
 │Variable Set and Position  │Variable│
 ├───────────────────────────┼────────┤