From: Ben Pfaff Date: Fri, 9 Jan 2026 15:41:35 +0000 (-0800) Subject: Change style for footnote markers in text output. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1d1ad868041fe4aa0d794163115eba250aad54ae;p=pspp Change style for footnote markers in text output. --- diff --git a/rust/doc/src/commands/set.md b/rust/doc/src/commands/set.md index 774f57e197..bf0b0bb82c 100644 --- a/rust/doc/src/commands/set.md +++ b/rust/doc/src/commands/set.md @@ -255,8 +255,8 @@ subcommands are * `LEADZERO` Controls whether numbers with magnitude less than one are displayed with a zero before the decimal point. For example, with `SET - LEADZERO=OFF`, which is the default, one-half is shown as 0.5, and - with `SET LEADZERO=ON`, it is shown as .5. This setting affects + LEADZERO=OFF`, which is the default, one-half is shown as `0.5`, and + with `SET LEADZERO=ON`, it is shown as `.5`. This setting affects only the `F`, `COMMA`, and `DOT` formats. * `MDISPLAY` diff --git a/rust/doc/src/language/datasets/formats/basic.md b/rust/doc/src/language/datasets/formats/basic.md index 6f9aa47dbc..7d46bf297c 100644 --- a/rust/doc/src/language/datasets/formats/basic.md +++ b/rust/doc/src/language/datasets/formats/basic.md @@ -122,15 +122,25 @@ More details of basic numeric output formatting are given below: preferred to ordinary decimal notation without it. - Except in scientific notation, a decimal point is included only when - it is followed by a digit. If the integer part of the number being - output is 0, and a decimal point is included, then PSPP ordinarily - drops the zero before the decimal point. However, in `F`, `COMMA`, - or `DOT` formats, PSPP keeps the zero if [`SET - LEADZERO`](../../../commands/set.md#leadzero) is set to - `ON`. - - In scientific notation, the number always includes a decimal point, - even if it is not followed by a digit. + it is followed by a digit. In scientific notation, the number + always includes a decimal point, even if it is not followed by a + digit. + +- If the integer part of the number being output is 0, and a decimal + point is included, whether PSPP displays the zero before the decimal + point depends on the following factors: + + - For `F`, `COMMA`, or `DOT` formats, PSPP keeps the leading zero if + [`SET LEADZERO`](../../../commands/set.md#leadzero) is set to + `ON`. + + - For `PCT` and `DOLLAR`, PSPP drops the leading zero unless the + number is being output within a pivot table in PSPP output[^0]. + + [^0]: There is a further exception: PSPP drops the leading zero if + the number is being output within a pivot table as part of a + templated longer text string rather than as a number on its own. + These currently only appear in SPV files written by SPSS. - A negative number includes a minus sign only in the presence of a nonzero digit: -0.01 is output as `-.01` in `F4.2` format but as diff --git a/rust/pspp/src/output/pivot/testdata/footnote_alphabetic_subscript.expected b/rust/pspp/src/output/pivot/testdata/footnote_alphabetic_subscript.expected index 4878aa099c..b394e850bb 100644 --- a/rust/pspp/src/output/pivot/testdata/footnote_alphabetic_subscript.expected +++ b/rust/pspp/src/output/pivot/testdata/footnote_alphabetic_subscript.expected @@ -1,12 +1,12 @@ Pivot Table with Alphabetic Subscript Footnotes[*] -╭────────────┬──────────────────╮ -│ │ A[*] │ -│ ├───────┬──────────┤ -│Corner[*][b]│ B[b] │ C[*][b] │ -├────────────┼───────┼──────────┤ -│D[b] E[*] │ .00│ 1.00[*]│ -│ F[*][b]│2.00[b]│3.00[*][b]│ -╰────────────┴───────┴──────────╯ +╭───────────┬─────────────────╮ +│ │ A[*] │ +│ ├───────┬─────────┤ +│Corner[*,b]│ B[b] │ C[*,b] │ +├───────────┼───────┼─────────┤ +│D[b] E[*] │ .00│ 1.00[*]│ +│ F[*,b]│2.00[b]│3.00[*,b]│ +╰───────────┴───────┴─────────╯ Caption[*] *. First footnote b. Second footnote diff --git a/rust/pspp/src/output/pivot/testdata/footnote_alphabetic_superscript.expected b/rust/pspp/src/output/pivot/testdata/footnote_alphabetic_superscript.expected index c989f62f8a..73475f75d4 100644 --- a/rust/pspp/src/output/pivot/testdata/footnote_alphabetic_superscript.expected +++ b/rust/pspp/src/output/pivot/testdata/footnote_alphabetic_superscript.expected @@ -1,12 +1,12 @@ Pivot Table with Alphabetic Superscript Footnotes[*] -╭────────────┬──────────────────╮ -│ │ A[*] │ -│ ├───────┬──────────┤ -│Corner[*][b]│ B[b] │ C[*][b] │ -├────────────┼───────┼──────────┤ -│D[b] E[*] │ .00│ 1.00[*]│ -│ F[*][b]│2.00[b]│3.00[*][b]│ -╰────────────┴───────┴──────────╯ +╭───────────┬─────────────────╮ +│ │ A[*] │ +│ ├───────┬─────────┤ +│Corner[*,b]│ B[b] │ C[*,b] │ +├───────────┼───────┼─────────┤ +│D[b] E[*] │ .00│ 1.00[*]│ +│ F[*,b]│2.00[b]│3.00[*,b]│ +╰───────────┴───────┴─────────╯ Caption[*] *. First footnote b. Second footnote diff --git a/rust/pspp/src/output/pivot/testdata/footnote_hidden.expected b/rust/pspp/src/output/pivot/testdata/footnote_hidden.expected index ce76a3f630..b67a8c98d3 100644 --- a/rust/pspp/src/output/pivot/testdata/footnote_hidden.expected +++ b/rust/pspp/src/output/pivot/testdata/footnote_hidden.expected @@ -1,11 +1,11 @@ Pivot Table with Alphabetic Subscript Footnotes[*] -╭────────────┬──────────────────╮ -│ │ A[*] │ -│ ├───────┬──────────┤ -│Corner[*][b]│ B[b] │ C[*][b] │ -├────────────┼───────┼──────────┤ -│D[b] E[*] │ .00│ 1.00[*]│ -│ F[*][b]│2.00[b]│3.00[*][b]│ -╰────────────┴───────┴──────────╯ +╭───────────┬─────────────────╮ +│ │ A[*] │ +│ ├───────┬─────────┤ +│Corner[*,b]│ B[b] │ C[*,b] │ +├───────────┼───────┼─────────┤ +│D[b] E[*] │ .00│ 1.00[*]│ +│ F[*,b]│2.00[b]│3.00[*,b]│ +╰───────────┴───────┴─────────╯ Caption[*] b. Second footnote diff --git a/rust/pspp/src/output/pivot/testdata/footnote_numeric_subscript.expected b/rust/pspp/src/output/pivot/testdata/footnote_numeric_subscript.expected index 82c1ccf679..6a466006fe 100644 --- a/rust/pspp/src/output/pivot/testdata/footnote_numeric_subscript.expected +++ b/rust/pspp/src/output/pivot/testdata/footnote_numeric_subscript.expected @@ -1,12 +1,12 @@ Pivot Table with Numeric Subscript Footnotes[*] -╭────────────┬──────────────────╮ -│ │ A[*] │ -│ ├───────┬──────────┤ -│Corner[*][2]│ B[2] │ C[*][2] │ -├────────────┼───────┼──────────┤ -│D[2] E[*] │ .00│ 1.00[*]│ -│ F[*][2]│2.00[2]│3.00[*][2]│ -╰────────────┴───────┴──────────╯ +╭───────────┬─────────────────╮ +│ │ A[*] │ +│ ├───────┬─────────┤ +│Corner[*,2]│ B[2] │ C[*,2] │ +├───────────┼───────┼─────────┤ +│D[2] E[*] │ .00│ 1.00[*]│ +│ F[*,2]│2.00[2]│3.00[*,2]│ +╰───────────┴───────┴─────────╯ Caption[*] *. First footnote 2. Second footnote diff --git a/rust/pspp/src/output/pivot/testdata/footnote_numeric_superscript.expected b/rust/pspp/src/output/pivot/testdata/footnote_numeric_superscript.expected index c6498624cc..27a25e63fa 100644 --- a/rust/pspp/src/output/pivot/testdata/footnote_numeric_superscript.expected +++ b/rust/pspp/src/output/pivot/testdata/footnote_numeric_superscript.expected @@ -1,12 +1,12 @@ Pivot Table with Numeric Superscript Footnotes[*] -╭────────────┬──────────────────╮ -│ │ A[*] │ -│ ├───────┬──────────┤ -│Corner[*][2]│ B[2] │ C[*][2] │ -├────────────┼───────┼──────────┤ -│D[2] E[*] │ .00│ 1.00[*]│ -│ F[*][2]│2.00[2]│3.00[*][2]│ -╰────────────┴───────┴──────────╯ +╭───────────┬─────────────────╮ +│ │ A[*] │ +│ ├───────┬─────────┤ +│Corner[*,2]│ B[2] │ C[*,2] │ +├───────────┼───────┼─────────┤ +│D[2] E[*] │ .00│ 1.00[*]│ +│ F[*,2]│2.00[2]│3.00[*,2]│ +╰───────────┴───────┴─────────╯ Caption[*] *. First footnote 2. Second footnote diff --git a/rust/pspp/src/output/pivot/value.rs b/rust/pspp/src/output/pivot/value.rs index aad9a9543d..fe88f63c50 100644 --- a/rust/pspp/src/output/pivot/value.rs +++ b/rust/pspp/src/output/pivot/value.rs @@ -36,6 +36,7 @@ use crate::{ variable::{VarType, Variable}, }; use chrono::{NaiveDateTime, NaiveTime}; +use itertools::Itertools; use serde::{ Serialize, Serializer, ser::{SerializeMap, SerializeStruct}, @@ -612,8 +613,15 @@ impl Display for DisplayValue<'_> { write!(f, "{delimiter}{subscript}")?; } - for footnote in self.footnotes { - write!(f, "[{}]", footnote.display_marker(&self.options))?; + if !self.footnotes.is_empty() { + write!( + f, + "[{}]", + self.footnotes + .iter() + .map(|f| f.display_marker(&self.options)) + .format(",") + )?; } Ok(()) diff --git a/rust/pspp/src/spv/testdata/legacy16.expected b/rust/pspp/src/spv/testdata/legacy16.expected index b8cf7896bc..11a74d319c 100644 --- a/rust/pspp/src/spv/testdata/legacy16.expected +++ b/rust/pspp/src/spv/testdata/legacy16.expected @@ -11,7 +11,7 @@ │ Refused AGE│59.0[1]│. │50.0[1]│. │54.5│ 6.4│ │ Total AGE│ 52.1│ 9.1│ 51.8│ 10.7│51.9│ 10.0│ ╰────────────────────────┴───────┴──────────────────┴───────┴──────────────────┴────┴──────────────────╯ -Note: Values in the same row and subtable not sharing the same subscript are significantly different at p< 0.05 in the two-sided test of equality for column means. Cells with no subscript are not included in the test. Tests assume equal variances.[2][3] +Note: Values in the same row and subtable not sharing the same subscript are significantly different at p< 0.05 in the two-sided test of equality for column means. Cells with no subscript are not included in the test. Tests assume equal variances.[2,3] 1. This category is not used in comparisons because the sum of case weights is less than two. 2. Tests are adjusted for all pairwise comparisons within a row of each innermost subtable using the Bonferroni correction. 3. Pairwise comparisons are not performed for some subtables because of numerical problems. diff --git a/rust/pspp/src/spv/testdata/legacy9.expected b/rust/pspp/src/spv/testdata/legacy9.expected index 9e88b6901c..dfbcded95d 100644 --- a/rust/pspp/src/spv/testdata/legacy9.expected +++ b/rust/pspp/src/spv/testdata/legacy9.expected @@ -1,5 +1,5 @@ Analysis -Test: Duncan[a][b] +Test: Duncan[a,b] │ Subset SP36 N│ 1 ───────┼───────