From: Ben Pfaff Date: Sun, 5 Jul 2026 07:59:28 +0000 (-0700) Subject: Update expected results. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d8f3e9d49291dfc4ee3078346de8ec8cd79e9da;p=pspp Update expected results. --- diff --git a/rust/doc/book.toml b/rust/doc/book.toml index 7f9d861cd4..a8acf5c1f6 100644 --- a/rust/doc/book.toml +++ b/rust/doc/book.toml @@ -1,7 +1,6 @@ [book] authors = ["Ben Pfaff"] language = "en" -multilingual = false src = "src" title = "GNU PSPP" @@ -9,6 +8,7 @@ title = "GNU PSPP" mathjax-support = true [output.linkcheck] +optional = true [preprocessor.toc] command = "mdbook-toc" diff --git a/rust/doc/src/commands/set.md b/rust/doc/src/commands/set.md index bf0b0bb82c..c125e930de 100644 --- a/rust/doc/src/commands/set.md +++ b/rust/doc/src/commands/set.md @@ -414,7 +414,7 @@ SET System file subcommands affect the default format of system files produced by PSPP. These subcommands are -* `SCOMPRESSION` +* `SCOMPRESSION` Whether system files created by `SAVE` or `XSAVE` are compressed by default. The default is `ON`. diff --git a/rust/pspp/src/spv/read/graph.rs b/rust/pspp/src/spv/read/graph.rs index 2ddab43163..7b98783956 100644 --- a/rust/pspp/src/spv/read/graph.rs +++ b/rust/pspp/src/spv/read/graph.rs @@ -49,7 +49,7 @@ use svg::{ }; use crate::{ - data::Datum, + data::{Datum, OwnedDatum}, format::{Type, UncheckedFormat}, locale::{Item, Locale, data::EN}, output::{ @@ -514,7 +514,7 @@ impl Visualization { domain, formatter: formatter.unwrap_or_else(|| Formatter::default_for_locale(locale)), axis: axis2, - label: dbg!(axis2.and_then(|axis| axis.label.as_ref())), + label: axis2.and_then(|axis| axis.label.as_ref()), major_ticks: axis2.and_then(|axis| axis.major_ticks.as_ref()), }; } @@ -675,6 +675,7 @@ impl Visualization { &mut axis_domains, styles, )?; + dbg!(&axis_domains); let elements = self.pass( &graph, locale, @@ -684,6 +685,7 @@ impl Visualization { &mut axis_domains, styles, )?; + dbg!(&axis_domains); let font_metrics = FontMetrics::new(); let font_height = font_metrics.measure("0")[Axis2::Y]; @@ -712,20 +714,16 @@ impl Visualization { if axis_domains[Axis3::X].label.is_some() { rect.0[Axis2::Y].1 -= font_height; } - dbg!(&rect); let facet_levels = graph.facet_levels(); let faceting = graph .faceting() .map(|f| f.decode(&series, &facet_levels)) .unwrap_or_default(); - dbg!(&faceting); let x_facets = FacetIterator::new(&faceting[Axis2::X]).into_values(); - dbg!(AxisFacets::new(&faceting[Axis2::X])); let nx_facets = x_facets.len(); let y_facets = FacetIterator::new(&faceting[Axis2::Y]).into_values(); - dbg!(AxisFacets::new(&faceting[Axis2::Y])); let ny_facets = y_facets.len(); let mut heading_heights = EnumMap::from_fn(|_| 0.0); @@ -761,14 +759,14 @@ impl Visualization { ); let top = headings[Axis2::X] - .render(Side::Top) + .render(Side::Top, 0.0) .set("c:description", "X axis facets above graph") .set( "transform", format!("translate({} {})", inner.0[Axis2::X].0, rect.0[Axis2::Y].0), ); let bottom = headings[Axis2::X] - .render(Side::Bottom) + .render(Side::Bottom, 0.0) .set("c:description", "X axis facets below graph") .set( "transform", @@ -776,7 +774,7 @@ impl Visualization { ); let left = headings[Axis2::Y] - .render(Side::Top) + .render(Side::Top, -90.0) .set("c:description", "Y axis facets on left side of graph") .set("transform", { let x = rect.0[Axis2::X].0; @@ -784,7 +782,7 @@ impl Visualization { format!("rotate(-90 {x} {y}) translate({x} {y})") }); let right = headings[Axis2::Y] - .render(Side::Bottom) + .render(Side::Bottom, -90.0) .set("c:description", "Y axis facets on right side of graph") .set("transform", { let x = rect.0[Axis2::X].1; @@ -1159,8 +1157,8 @@ impl Visualization { graph_svg.append(bottom); graph_svg.append(left); graph_svg.append(right); - graph_svg.append(rect.as_svg().set("fill", "none").set("stroke", "red")); - graph_svg.append(inner.as_svg().set("fill", "none").set("stroke", "green")); + //graph_svg.append(rect.as_svg().set("fill", "none").set("stroke", "red")); + //graph_svg.append(inner.as_svg().set("fill", "none").set("stroke", "green")); Ok(graph_svg) } } @@ -1547,7 +1545,6 @@ impl Variable for SourceVariable { // XXX warn about missing variable Vec::new() }; - dbg!(&data); let formatter = self.format.as_ref().map_or_else( || Formatter::default_for_locale(locale), |format| Formatter::new(format, locale), @@ -1717,7 +1714,15 @@ impl<'a> AxisDomain<'a> { if self.domain.lookup(value).is_some() { let left = index as f64 / values.len() as f64; let right = (index + 1) as f64 / values.len() as f64; - ticks.push((left.midpoint(right), label.clone().unwrap_or_default())); + let value = left.midpoint(right); + ticks.push(( + value, + label.clone().unwrap_or_else(|| { + self.formatter + .display(&OwnedDatum::Number(Some(value))) + .to_string() + }), + )); } } } @@ -1999,7 +2004,6 @@ impl RawDomain for IntervalDomain { } } } else { - dbg!(variable.reference.as_str()); todo!() } } @@ -2692,6 +2696,7 @@ impl<'a> Element<'a> { if let Datum::Number(Some(number)) = &value.value { value.value = Datum::Number(binning.bin(*number)); } + // XXX set value.label } } x.categorical = true; @@ -4936,6 +4941,8 @@ struct FacetHeadings<'a> { /// Currently there's always exactly one of these for an axis, although /// perhaps there should be up to 2. axis_domain: &'a AxisDomain<'a>, + + rotate_ticks: bool, } struct FacetAxisHeight<'a> { @@ -4996,7 +5003,6 @@ impl<'a> FacetHeadings<'a> { let axis_facets = AxisFacets::new(facets); let n_facets = axis_facets.len(); let span = Span(0.0, width).subdivide(n_facets, 5.0); - println!("span: {span:?}"); let facets = axis_facets .rows .into_iter() @@ -5018,7 +5024,6 @@ impl<'a> FacetHeadings<'a> { if !label.is_empty() { let column_width = span.range(&column.columns).length(); let tmp = font_metrics.measure_height_for_width(&label, column_width); - println!("height of {label} with width {column_width:.0} is {tmp:.0}"); facet_label_height = facet_label_height.max(tmp); } } @@ -5085,10 +5090,11 @@ impl<'a> FacetHeadings<'a> { ticks, facets, n_facets, + rotate_ticks, } } - fn render(&self, side: Side) -> Group { + fn render(&self, side: Side, rotation: f64) -> Group { let span = Span(0.0, self.width).subdivide(self.n_facets, 5.0); let mut group = Group::new(); @@ -5098,10 +5104,10 @@ impl<'a> FacetHeadings<'a> { group: &mut Group, span: &DividedSpan, y: f64, - height: f64, + _height: f64, ) { for facet_span in (0..this.n_facets).map(|index| span.nth(index)) { - for (frac, label) in ticks { + for (frac, _label) in ticks { let x = facet_span.frac(*frac); group.append( Line::new() @@ -5121,19 +5127,31 @@ impl<'a> FacetHeadings<'a> { group: &mut Group, span: &DividedSpan, y: f64, - height: f64, + _height: f64, + rotation: f64, ) { for facet_span in (0..this.n_facets).map(|index| span.nth(index)) { for (frac, label) in ticks { let x = facet_span.frac(*frac); let label = if label.is_empty() { "x" } else { &label }; - group.append( - svg::node::element::Text::new(dbg!(label)) - .set("x", x) - .set("y", y) - .set("dominant-baseline", "hanging") - .set("text-anchor", "middle"), - ); + if rotation == 0.0 { + group.append( + svg::node::element::Text::new(label) + .set("x", x) + .set("y", y) + .set("dominant-baseline", "hanging") + .set("text-anchor", "middle"), + ); + } else { + group.append( + svg::node::element::Text::new(label) + .set("x", x) + .set("y", y) + .set("dominant-baseline", "middle") + .set("text-anchor", "right") + .set("transform", format!("rotate(90 {x} {y})")), + ); + } } } } @@ -5144,7 +5162,7 @@ impl<'a> FacetHeadings<'a> { && side == Side::Bottom { render_ticks(self, ticks, &mut group, &span, y, *height); - render_tick_labels(self, ticks, &mut group, &span, y + 10.0, *height); + render_tick_labels(self, ticks, &mut group, &span, y + 10.0, *height, rotation); y += height; } /* @@ -5158,7 +5176,7 @@ impl<'a> FacetHeadings<'a> { .set("stroke", "red"), );*/ for axis in self.axes.iter().filter(|axis| axis.side == side) { - if dbg!(axis.axis.combine_axis_labels) { + if axis.axis.combine_axis_labels { group.append( svg::node::element::Text::new(&axis.text) .set("x", self.width / 2.0) @@ -5167,7 +5185,7 @@ impl<'a> FacetHeadings<'a> { .set("text-anchor", "middle"), ); } else { - for index in dbg!(0..self.n_facets) { + for index in 0..self.n_facets { group.append( svg::node::element::Text::new(&axis.text) .set("x", span.nth(index).midpoint()) @@ -5227,7 +5245,6 @@ impl<'a> FacetHeadings<'a> { for column in &height.row.columns { let label = column.label(&height.row.series); if !label.is_empty() { - dbg!(&label); let span = span.range(&column.columns); group.append( svg::node::element::Text::new(label) @@ -5244,7 +5261,19 @@ impl<'a> FacetHeadings<'a> { && *ticks_side == side && side == Side::Top { - render_tick_labels(self, ticks, &mut group, &span, y, *height); + render_tick_labels( + self, + ticks, + &mut group, + &span, + if rotation != 0.0 { + y + (*height - 20.0) + } else { + y + }, + *height, + rotation, + ); render_ticks( self, ticks, diff --git a/rust/pspp/src/spv/testdata/graph1.expected.svg b/rust/pspp/src/spv/testdata/graph1.expected.svg index cd8df20a49..f8c099091e 100644 --- a/rust/pspp/src/spv/testdata/graph1.expected.svg +++ b/rust/pspp/src/spv/testdata/graph1.expected.svg @@ -1,4 +1,4 @@ - + Group Name @@ -6,68 +6,72 @@ Group Name ROC Curve - - - + + + + + + + + + + + + + + + + 0 - - + 0,2 - - + 0,4 - - + 0,6 - - + 0,8 - - + 1 - + X Axis - - - + + + +Y Axis + + 0 - - + 0,2 - - + 0,4 - - + 0,6 - - + 0,8 - - + 1 - -Y Axis - - - - - - - + + + + + + + diff --git a/rust/pspp/src/spv/testdata/graph2.expected.svg b/rust/pspp/src/spv/testdata/graph2.expected.svg index 0de1665fd4..f1020c90ce 100644 --- a/rust/pspp/src/spv/testdata/graph2.expected.svg +++ b/rust/pspp/src/spv/testdata/graph2.expected.svg @@ -1,144 +1,156 @@ - + Title - - - + + + + + + + + + + + 10 - - + 15 - + V2 - - - + + + 0 - - + 10 - - + 20 - - + 30 - - + 40 - - + 50 - - + 60 - - - - - + + + + + + + + - - - + + + + + + + + + + + + 0.575 - - + 0.58 - - + 0.585 - + V1 - - - + + + 0 - - + 10 - - + 20 - - + 30 - - + 40 - - + 50 - - - - - + + + + + + + - - - + + + + + + + + + + + + 30 - - + 35 - - + 40 - + V3 - - - + + + 0 - - + 10 - - + 20 - - + 30 - - - - - + + + + + diff --git a/rust/pspp/src/spv/testdata/graph3.expected.svg b/rust/pspp/src/spv/testdata/graph3.expected.svg index 6c5af5e496..8e6c3dcb0d 100644 --- a/rust/pspp/src/spv/testdata/graph3.expected.svg +++ b/rust/pspp/src/spv/testdata/graph3.expected.svg @@ -1,79 +1,86 @@ - + - - - + + + + + + + + + + + + + + + + + + + + + + + + + Value0 - - + Value1 - + V0 - - - + + + +Percent + + .0% - - + 10.0% - - + 20.0% - - + 30.0% - -no - - - - + .0% - - + 10.0% - - + 20.0% - - + 30.0% - -yes + + + + + + + + + + + +Graph0 - -Percent + +no + + +yes - - - - - - - - - - - - - - - - - - - diff --git a/rust/pspp/src/spv/testdata/graph4.expected.svg b/rust/pspp/src/spv/testdata/graph4.expected.svg index 23056aa2e0..ee53b57d3f 100644 --- a/rust/pspp/src/spv/testdata/graph4.expected.svg +++ b/rust/pspp/src/spv/testdata/graph4.expected.svg @@ -1,56 +1,29 @@ - + - - - -0 - - - -10 - - - -20 - - - -30 - - - -40 - - - -50 - - - - -0 - - -yes - - - - -0 - - -no - - + - + + - + - - + + + + + + + +Graph0 + + +no + + +yes + diff --git a/rust/pspp/src/spv/testdata/graph5.expected.svg b/rust/pspp/src/spv/testdata/graph5.expected.svg index b2f09320dc..07bf487766 100644 --- a/rust/pspp/src/spv/testdata/graph5.expected.svg +++ b/rust/pspp/src/spv/testdata/graph5.expected.svg @@ -1,192 +1,203 @@ - + - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Variable 11 - - - + +V11-1 - -Variable 4 + +V11-2 + + + + + + + + +.25 + + +.75 - - - - + +.25 - - - + +.75 - + Variable 4 - - - + + + +Frequency + + 0 - - + 1 - - + 2 - - + 3 - - + 4 - - + 5 - - + 6 - -V12-4 - - - - + 0 - - + 1 - - + 2 - - + 3 - - + 4 - - + 5 - - + 6 - -V12-5 - - - - + 0 - - + 1 - - + 2 - - + 3 - - + 4 - - + 5 - - + 6 - -V12-7 - - - - + 0 - - + 1 - - + 2 - - + 3 - - + 4 - - + 5 - - + 6 - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +Variable 12 + + +V12-4 + + +V12-5 + + V12-6 - -Frequency + +V12-7 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -