From: Ben Pfaff Date: Fri, 9 Jan 2026 22:35:32 +0000 (-0800) Subject: fixes X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=311ba451668565366b9657b91e8300c4905dd39b;p=pspp fixes --- diff --git a/rust/doc/src/spv/light-detail.md b/rust/doc/src/spv/light-detail.md index 2eadec547c..5797a045b7 100644 --- a/rust/doc/src/spv/light-detail.md +++ b/rust/doc/src/spv/light-detail.md @@ -805,14 +805,21 @@ Group => `name` is the name of the category (or group). -A `Leaf` represents a leaf category. The `Leaf`'s `leaf-index` is a -nonnegative integer unique within the `Dimension` and less than -`n-categories` in the Dimension. If the user does not sort or -rearrange the categories, then `leaf-index` starts at 0 for the first -`Leaf` in the dimension and increments by 1 with each successive -`Leaf`. If the user does sort or rearrange the categories, then the -order of categories in the file reflects that change and `leaf-index` -reflects the original order. +A `Leaf` represents a leaf category. The `Leaf`'s `leaf-index` is +ordinarily a integer unique within the `Dimension` in the range +`0..n-categories`: + +- If the user does not sort or rearrange the categories, then + `leaf-index` starts at 0 for the first `Leaf` in the dimension and + increments by 1 with each successive `Leaf`. + +- If the user does sort or rearrange the categories, then the order of + categories in the file reflects that change and `leaf-index` + reflects the original order. + +- A `leaf-index` of -1 indicates a deleted category. A reader can + ignore these categories. The remaining `n` categories have + `leaf-index` in the range `0..n`. A dimension can have no leaf categories at all. A table that contains such a dimension necessarily has no data at all. diff --git a/rust/pspp/src/spv/read/light.rs b/rust/pspp/src/spv/read/light.rs index b3b9f4526b..13598369eb 100644 --- a/rust/pspp/src/spv/read/light.rs +++ b/rust/pspp/src/spv/read/light.rs @@ -179,7 +179,7 @@ impl LightTable { .iter() .map(|cell| { ( - PrecomputedIndex(cell.index as usize), + PrecomputedIndex(dbg!(cell.index) as usize), cell.value.decode(encoding, &footnotes, warn), ) }) @@ -1718,8 +1718,10 @@ impl Category { let name = self.name.decode(encoding, footnotes, warn); match &self.child { Child::Leaf { leaf_index } => { - ptod.push(*leaf_index as usize); - group.push(pivot::Leaf::new(name)); + if *leaf_index >= 0 { + ptod.push(*leaf_index as usize); + group.push(pivot::Leaf::new(name)); + } } Child::Group { merge: true, @@ -1751,7 +1753,7 @@ enum Child { #[br(magic(0u16), parse_with(parse_bool), temp)] _x24: bool, #[br(magic(b"\x02\0\0\0"))] - leaf_index: u32, + leaf_index: i32, #[br(magic(0u32), temp)] _tail: (), }, diff --git a/rust/pspp/src/spv/read/tests.rs b/rust/pspp/src/spv/read/tests.rs index 9ab4e7b6ca..40fefc6f9b 100644 --- a/rust/pspp/src/spv/read/tests.rs +++ b/rust/pspp/src/spv/read/tests.rs @@ -44,6 +44,12 @@ fn light5() { test_raw_spvfile("light5", None); } +/// Test categories to be deleted due to negative `leaf-index`. +#[test] +fn light6() { + test_raw_spvfile("light6", None); +} + #[test] fn legacy1() { test_raw_spvfile("legacy1", None); diff --git a/rust/pspp/src/spv/testdata/light5.expected b/rust/pspp/src/spv/testdata/light5.expected new file mode 100644 index 0000000000..8acd5b12b8 --- /dev/null +++ b/rust/pspp/src/spv/testdata/light5.expected @@ -0,0 +1,7 @@ + Hypothesis Test Summary + Null Hypothesis │ Test │Sig.[a,b]│ Decision +─────────────────────────────────────────────────────────────────────────────────────────┼────────────────────────────────────────────────────────────────┼─────────┼─────────────────────────── +1 The distributions of Variable0000001, Variable0000002 and Variable0000003 are the same.│Related-Samples Friedman's Two-Way Analysis of Variance by Ranks│ .164│Retain the null hypothesis. +─────────────────────────────────────────────────────────────────────────────────────────┴────────────────────────────────────────────────────────────────┴─────────┴─────────────────────────── +a. The significance level is .050. +b. Asymptotic significance is displayed. diff --git a/rust/pspp/src/spv/testdata/light5.spv b/rust/pspp/src/spv/testdata/light5.spv new file mode 100644 index 0000000000..55951cd1f5 Binary files /dev/null and b/rust/pspp/src/spv/testdata/light5.spv differ diff --git a/rust/pspp/src/spv/testdata/light6.expected b/rust/pspp/src/spv/testdata/light6.expected new file mode 100644 index 0000000000..d0ceed0749 --- /dev/null +++ b/rust/pspp/src/spv/testdata/light6.expected @@ -0,0 +1,5 @@ +xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx + Frequency│Percent +────────────────────────┼─────── +Missing System 21│ 100.0 +────────────────────────┴─────── diff --git a/rust/pspp/src/spv/testdata/light6.spv b/rust/pspp/src/spv/testdata/light6.spv new file mode 100644 index 0000000000..b48fd3780d Binary files /dev/null and b/rust/pspp/src/spv/testdata/light6.spv differ