From: Ben Pfaff Date: Sun, 13 Apr 2025 16:24:17 +0000 (-0700) Subject: remove mandatory title X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3f007a443c9d958c9e9c67eb9693e47a216b1388;p=pspp remove mandatory title --- diff --git a/rust/pspp/src/output/pivot/mod.rs b/rust/pspp/src/output/pivot/mod.rs index cf98272c6e..2e972dc104 100644 --- a/rust/pspp/src/output/pivot/mod.rs +++ b/rust/pspp/src/output/pivot/mod.rs @@ -1398,7 +1398,7 @@ where } impl PivotTable { - pub fn new(title: impl Into, dimensions_and_axes: Vec<(Axis3, Dimension)>) -> Self { + pub fn new(dimensions_and_axes: Vec<(Axis3, Dimension)>) -> Self { let mut dimensions = Vec::new(); let mut axes = EnumMap::::default(); for (axis, dimension) in dimensions_and_axes { @@ -1407,7 +1407,6 @@ impl PivotTable { } Self { look: Settings::global().look.clone(), - title: Some(Box::new(title.into())), current_layer: repeat_n(0, axes[Axis3::Z].dimensions.len()).collect(), axes, dimensions, diff --git a/rust/pspp/src/output/pivot/test.rs b/rust/pspp/src/output/pivot/test.rs index 6b4a0155cc..e0a72869c9 100644 --- a/rust/pspp/src/output/pivot/test.rs +++ b/rust/pspp/src/output/pivot/test.rs @@ -31,7 +31,8 @@ fn d1(title: &str, axis: Axis3) -> PivotTable { .with("a2") .with("a3"), ); - let mut pt = PivotTable::new(Value::new_text(title), vec![(axis, dimension)]) + let mut pt = PivotTable::new(vec![(axis, dimension)]) + .with_title(title) .with_look(Arc::new(test_look())); for i in 0..3 { pt.insert(&[i], Value::new_integer(Some(i as f64))); @@ -97,7 +98,7 @@ fn d2(title: &str, axes: [Axis3; 2], dimension_labels: Option) -> .with("b3"), ); - let mut pt = PivotTable::new(Value::new_text(title), vec![(axes[0], d1), (axes[1], d2)]); + let mut pt = PivotTable::new(vec![(axes[0], d1), (axes[1], d2)]).with_title(title); let mut i = 0; for b in 0..3 { for a in 0..3 { @@ -522,8 +523,9 @@ fn d3() { .with("c5"), ), ); - let mut pt = - PivotTable::new("Column x b1 x a1", vec![a, b, c]).with_look(Arc::new(test_look())); + let mut pt = PivotTable::new(vec![a, b, c]) + .with_title("Column x b1 x a1") + .with_look(Arc::new(test_look())); let mut i = 0; for c in 0..5 { for b in 0..4 { @@ -654,9 +656,8 @@ fn footnote_table(show_f0: bool) -> PivotTable { ), ); let look = test_look().with_row_label_position(LabelPosition::Nested); - let mut pt = PivotTable::new( + let mut pt = PivotTable::new(vec![a, d]).with_title( Value::new_text("Pivot Table with Alphabetic Subscript Footnotes").with_footnote(&f0), - vec![a, d], ); pt.insert(&[0, 0], Value::new_number(Some(0.0))); pt.insert(&[1, 0], Value::new_number(Some(1.0)).with_footnote(&f0)); @@ -802,7 +803,9 @@ b. Second footnote #[test] fn no_dimension() { - let pivot_table = PivotTable::new("No Dimensions", vec![]).with_look(Arc::new(test_look())); + let pivot_table = PivotTable::new(vec![]) + .with_title("No Dimensions") + .with_look(Arc::new(test_look())); assert_rendering( &pivot_table, "No Dimensions @@ -817,12 +820,15 @@ fn empty_dimensions() { let look = Arc::new(test_look().with_omit_empty(false)); let d1 = (Axis3::X, Dimension::new(Group::new("a"))); - let pivot_table = PivotTable::new("One Empty Dimension", vec![d1]).with_look(look.clone()); + let pivot_table = PivotTable::new(vec![d1]) + .with_title("One Empty Dimension") + .with_look(look.clone()); assert_rendering(&pivot_table, "One Empty Dimension\n"); let d1 = (Axis3::X, Dimension::new(Group::new("a"))); let d2 = (Axis3::X, Dimension::new(Group::new("b").with_label_shown())); - let pivot_table = PivotTable::new(Value::new_text("Two Empty Dimensions"), vec![d1, d2]) + let pivot_table = PivotTable::new(vec![d1, d2]) + .with_title("Two Empty Dimensions") .with_look(look.clone()); assert_rendering(&pivot_table, "Two Empty Dimensions\n"); @@ -832,8 +838,9 @@ fn empty_dimensions() { Axis3::X, Dimension::new(Group::new("c").with("c1").with("c2")), ); - let pivot_table = - PivotTable::new("Three Dimensions, Two Empty", vec![d1, d2, d3]).with_look(look.clone()); + let pivot_table = PivotTable::new(vec![d1, d2, d3]) + .with_title("Three Dimensions, Two Empty") + .with_look(look.clone()); assert_rendering(&pivot_table, "Three Dimensions, Two Empty\n"); } @@ -849,7 +856,7 @@ fn empty_groups() { Dimension::new(Group::new("b").with(Group::new("b1")).with("b2").with("b3")), ); - let mut pt = PivotTable::new("Empty Groups", vec![d1, d2]); + let mut pt = PivotTable::new(vec![d1, d2]).with_title("Empty Groups"); let mut i = 0; for b in 0..2 { for a in 0..2 { @@ -913,7 +920,8 @@ fn d4( .with("d3"), ), ); - let mut pivot_table = PivotTable::new(title, vec![a, b, c, d]) + let mut pivot_table = PivotTable::new(vec![a, b, c, d]) + .with_title(title) .with_look(Arc::new(test_look().with_borders(borders))); let mut i = 0; for d in 0..3 { @@ -1259,7 +1267,7 @@ fn small_numbers() { .with_label_shown(), ), ); - let mut pt = PivotTable::new("small numbers", vec![exponent, sign, rc]); + let mut pt = PivotTable::new(vec![exponent, sign, rc]).with_title("small numbers"); pt.insert_number(&[0, 0, 0], Some(1.0), Class::Other); pt.insert_number(&[1, 0, 0], Some(0.1), Class::Other); pt.insert_number(&[2, 0, 0], Some(0.01), Class::Other);