diff --git a/crates/doc/src/expr.rs b/crates/doc/src/expr.rs index bcd484d7d..d7f9b7cbd 100644 --- a/crates/doc/src/expr.rs +++ b/crates/doc/src/expr.rs @@ -304,6 +304,28 @@ pub fn value_in_unit(v: Value, unit: &str) -> f64 { } } +/// The number a reply reports for a value: millimetres for a length, degrees for an angle, +/// as-is for a unit-less or compound value. One meaning of `value` in every reply (#10747). +pub fn reported_value(v: Value) -> f64 { + match v.kind() { + Some(Kind::Angle) => v.v.to_degrees(), + _ => v.v, + } +} + +/// The number a person would read for `v`: the shortest decimal that reads back after +/// rounding off the last few bits (12 significant digits), so `30 deg` stored as +/// 29.999999999999996 reports 30 and `0.1 + 0.2` reports 0.3. Only what is *reported* +/// is rounded; stored values and evaluation keep full precision (#10747). +pub fn round_reported(v: f64) -> f64 { + if !v.is_finite() { + return v; + } + // `:.11e` keeps 12 significant digits; parsing back gives the f64 nearest that decimal, + // which serializes as the shortest form that reads back to it. + format!("{v:.11e}").parse().unwrap_or(v) +} + fn unit(name: &str) -> Option { UNITS.iter().find(|(n, _, _)| *n == name).map(|(_, k, s)| match k { Kind::Angle => Value::angle(*s), @@ -1637,4 +1659,36 @@ mod tests { defs[2].expr = "bad +".into(); assert!(eval_params(&defs, 1.0).1.contains_key("c")); } + + /// #10747: reported numbers are the shortest decimals that read back after rounding off + /// the last few bits (12 significant digits); stored values keep full precision. + #[test] + fn round_reported_reads_as_a_person_would() { + for (noisy, read) in [ + (30f64.to_radians().to_degrees(), 30.0), + (0.1 + 0.2, 0.3), + (3.0 * 25.4, 76.2), + (1.2 * 25.4, 30.48), + (29.999999999999996, 30.0), + (0.30000000000000004, 0.3), + (-0.1 - 0.2, -0.3), + ] { + assert_eq!(round_reported(noisy), read, "{noisy}"); + } + // A number with real digits of its own keeps them up to 12 significant digits. + assert_eq!(round_reported(1.234567890123), 1.23456789012); + assert_eq!(round_reported(1.0000000000001), 1.0); + // Zero and non-finite values pass through. + assert_eq!(round_reported(0.0), 0.0); + assert!(round_reported(f64::INFINITY).is_infinite()); + assert!(round_reported(f64::NAN).is_nan()); + } + + /// #10747: `value` means millimetres and degrees in every reply. + #[test] + fn reported_value_is_mm_and_degrees() { + assert_eq!(reported_value(Value::length(50.8)), 50.8); + assert_eq!(round_reported(reported_value(Value::angle(30f64.to_radians()))), 30.0); + assert_eq!(reported_value(Value::num(4.0)), 4.0); + } } diff --git a/crates/doc/src/params.rs b/crates/doc/src/params.rs index b480999fa..a605622ea 100644 --- a/crates/doc/src/params.rs +++ b/crates/doc/src/params.rs @@ -90,7 +90,11 @@ pub struct ParamRow { pub name: String, pub expression: String, pub unit: String, + /// Always millimetres for a length, degrees for an angle, whatever the parameter's own + /// unit — the same meaning `value` has in every reply (#10747). pub value: Option, + /// The value in the parameter's own `unit`, as the Parameters window shows it. + pub display_value: Option, pub error: Option, pub comment: String, /// "user", "sketch" (a dimension) or "feature". @@ -367,14 +371,20 @@ impl Document { } } let used_by = |n: &str| -> Vec { users.get(n).cloned().unwrap_or_default() }; - let value = |n: &str, k: Kind| vals.get(n).and_then(|v| v.to_kind(k).ok()).map(|x| if k == Kind::Angle { x.to_degrees() } else { x }); + let value = |n: &str, k: Kind| { + vals.get(n).and_then(|v| v.to_kind(k).ok()).map(|x| if k == Kind::Angle { x.to_degrees() } else { x }).map(expr::round_reported) + }; + // `value` is mm / degrees in every row (#10747); the parameter's own unit goes to + // `display_value`. Both carry the number a person would read, not the float noise. + let unified = |n: &str| vals.get(n).map(|v| expr::round_reported(expr::reported_value(*v))); let mut rows = Vec::new(); for p in &self.params { rows.push(ParamRow { name: p.name.clone(), expression: p.expr.clone(), unit: p.unit.clone(), - value: self.param_display_value(&vals, &p.name), + value: unified(&p.name), + display_value: self.param_display_value(&vals, &p.name).map(expr::round_reported), error: errs.get(&p.name).cloned(), comment: p.comment.clone(), source: if p.model { "sketch" } else { "user" }, @@ -396,6 +406,8 @@ impl Document { expression: e, unit: unit_of(k).into(), value: value(name, k), + // A feature input's own unit is mm / deg, so its display value is its value. + display_value: value(name, k), error: errs.get(name).cloned(), comment: self.param_comments.get(name).cloned().unwrap_or_default(), source: "feature", @@ -415,6 +427,7 @@ impl Document { expression: p.text.clone(), unit: crate::text_params::TEXT_UNIT.into(), value: None, + display_value: None, error: None, comment: p.comment.clone(), source: "user", @@ -460,7 +473,8 @@ impl Document { Ok(()) } - /// User parameters as CSV (`name,unit,expression,value,comment`). + /// User parameters as CSV (`name,unit,expression,value,comment`). The `value` column is the + /// number in the `unit` column, rounded for reading (#10747); import reads `expression`. pub fn params_csv(&self) -> String { let q = |s: &str| if s.contains([',', '"', '\r', '\n']) { format!("\"{}\"", s.replace('"', "\"\"")) } else { s.to_string() }; let mut out = String::from("name,unit,expression,value,comment,favorite\n"); @@ -470,7 +484,7 @@ impl Document { q(&r.name), q(&r.unit), q(&r.expression), - r.value.map(|v| format!("{v}")).unwrap_or_default(), + r.display_value.or(r.value).map(|v| format!("{v}")).unwrap_or_default(), q(&r.comment), r.favorite ); diff --git a/crates/engine/src/cmd/joints.rs b/crates/engine/src/cmd/joints.rs index 7bdd39296..3648dadbd 100644 --- a/crates/engine/src/cmd/joints.rs +++ b/crates/engine/src/cmd/joints.rs @@ -6,7 +6,7 @@ use std::collections::{BTreeMap, BTreeSet}; use serde_json::{Value, json}; -use solidcraft_doc::expr::Kind; +use solidcraft_doc::expr::{self, Kind}; use solidcraft_doc::joints::cam::{self, Cam, CamProfile, Follower}; use solidcraft_doc::joints::{self, Coupling, Joint, JointExprs, JointKind, JointOrigin, MotionLink, NamedOrigin, Size, Snap, XRef}; use solidcraft_geom::{Aabb3, Vec3}; @@ -232,7 +232,8 @@ fn sol_json(sol: &joints::Solution, p: &Value) -> Value { } /// A joint's values as `joint.list` gives them: degrees for angles, mm for distances, each with -/// its name and limits. +/// its name and limits. The numbers are rounded for reading (#10747); the joint keeps full +/// precision. pub(crate) fn named_values(j: &Joint, q: &[f64]) -> Vec { j.kind .dofs() @@ -240,8 +241,8 @@ pub(crate) fn named_values(j: &Joint, q: &[f64]) -> Vec { .enumerate() .map(|(i, n)| { let (v, angle) = (q.get(i).copied().unwrap_or(0.0), j.kind.is_angle(i)); - json!({"name": n, "value": if angle { v.to_degrees() } else { v }, "unit": if angle { "deg" } else { "mm" }, - "limits": j.limits.get(i).copied().flatten().map(|(a, b)| if angle { [a.to_degrees(), b.to_degrees()] } else { [a, b] })}) + json!({"name": n, "value": expr::round_reported(if angle { v.to_degrees() } else { v }), "unit": if angle { "deg" } else { "mm" }, + "limits": j.limits.get(i).copied().flatten().map(|(a, b)| if angle { [expr::round_reported(a.to_degrees()), expr::round_reported(b.to_degrees())] } else { [expr::round_reported(a), expr::round_reported(b)] })}) }) .collect() } @@ -1103,7 +1104,7 @@ fn held_values(s: &Session, j: &Joint, requested: &[f64], driven: &[usize], r: & continue; } let angle = j.kind.is_angle(i); - let shown = |v: f64| if angle { v.to_degrees() } else { v }; + let shown = |v: f64| expr::round_reported(if angle { v.to_degrees() } else { v }); let name = names.get(i).copied().unwrap_or("value"); let why = if let Some(l) = s.doc.assembly.links.iter().find(|l| l.b == j.id && l.ib == i) { let coupling = match &l.coupling { diff --git a/crates/engine/src/cmd/joints_tests.rs b/crates/engine/src/cmd/joints_tests.rs index e4614b1c9..44d38676f 100644 --- a/crates/engine/src/cmd/joints_tests.rs +++ b/crates/engine/src/cmd/joints_tests.rs @@ -2570,3 +2570,21 @@ fn driving_one_cylindrical_coordinate_preserves_the_other_expression_and_reports assert!(s.execute("joint.drive", &json!({"joint":joint,"index":bad,"value":0})).is_err()); } } + +/// #10747: driving a joint to 30 reports 30, not 29.999999999999996; the joint keeps +/// full precision. +#[test] +fn driving_an_angle_reports_the_number_a_person_would_read() { + let mut s = two_cubes(); + run( + &mut s, + "joint.create", + json!({"type": "revolute", "a": {"occurrence": "A", "point": [5.0, 5.0, 10.0]}, "b": {"occurrence": "B", "point": [25.0, 5.0, 10.0]}, "name": "Turn"}), + ); + let r = run(&mut s, "joint.drive", json!({"joint": "Turn", "value": 30})); + assert_eq!(r["values"][0]["value"], json!(30.0), "{r}"); + assert_eq!(r["requested"][0]["value"], json!(30.0), "{r}"); + // Only what is reported is rounded: the stored value keeps full precision. + let j = s.doc.assembly.joints.iter().find(|j| j.name == "Turn").unwrap(); + assert_ne!(j.values[0].to_degrees(), 30.0, "the stored angle keeps its bits"); +} diff --git a/crates/engine/src/cmd/parameters.rs b/crates/engine/src/cmd/parameters.rs index d8b89d0e5..cda10522b 100644 --- a/crates/engine/src/cmd/parameters.rs +++ b/crates/engine/src/cmd/parameters.rs @@ -23,8 +23,8 @@ pub static COMMANDS: &[CommandSpec] = &[ activation; driven parameters and restrictions wait for a configuration edit or activation)", ), CommandSpec::new("parameters.list", "List Parameters", list).icon("list").noundo().doc_only().params( - "favorites?: bool (only favourites), filter?: all|user|sketch|feature|favorites → parameters (name, expression, unit, value in its unit, \ - source, feature/input, comment, favorite, uses, used_by, error) and cycles", + "favorites?: bool (only favourites), filter?: all|user|sketch|feature|favorites → parameters (name, expression, unit, value (mm/deg in every \ + reply), display_value (in its own unit), source, feature/input, comment, favorite, uses, used_by, error) and cycles", ), CommandSpec::new("parameters.add", "Add User Parameter", add) .icon("new") @@ -177,8 +177,8 @@ fn change_param(s: &mut Session, p: &Value) -> Result { if let Some(t) = s.doc.text_param(&name) { out["text"] = json!(t.text); } - out["value"] = json!(vals.get(&name).map(|v| v.v)); - out["display_value"] = json!(s.doc.param_display_value(&vals, &name)); + out["value"] = json!(vals.get(&name).map(|v| expr::round_reported(expr::reported_value(*v)))); + out["display_value"] = json!(s.doc.param_display_value(&vals, &name).map(expr::round_reported)); out["recomputed"] = json!(s.model.last_recomputed); out["restored"] = json!(s.model.last_restored); out["errors"] = json!(failing(s)); @@ -280,7 +280,8 @@ fn change_many(s: &mut Session, changes: &Value, solved: &crate::SketchValues) - } s.settle_value_edit(solved)?; let (vals, _) = s.doc.param_values(); - let values: serde_json::Map = list.iter().map(|(n, _)| (n.clone(), json!(vals.get(n).map(|v| v.v)))).collect(); + let values: serde_json::Map = + list.iter().map(|(n, _)| (n.clone(), json!(vals.get(n).map(|v| expr::round_reported(expr::reported_value(*v)))))).collect(); let mut out = json!({"changed": values, "recomputed": s.model.last_recomputed, "restored": s.model.last_restored, "errors": failing(s)}); if !switched.is_empty() { out["switched"] = json!(switched); @@ -343,7 +344,7 @@ fn add(s: &mut Session, p: &Value) -> Result { return Ok(json!({"name": name, "unit": solidcraft_doc::text_params::TEXT_UNIT, "text": t.text, "value": null})); } Ok( - json!({"name": name, "unit": s.doc.param(&name).map(|x| x.unit.clone()), "value": vals.get(&name).map(|v| v.v), "display_value": s.doc.param_display_value(&vals, &name)}), + json!({"name": name, "unit": s.doc.param(&name).map(|x| x.unit.clone()), "value": vals.get(&name).map(|v| expr::round_reported(expr::reported_value(*v))), "display_value": s.doc.param_display_value(&vals, &name).map(expr::round_reported)}), ) } @@ -426,7 +427,9 @@ fn export(s: &mut Session, p: &Value) -> Result { .param_rows() .into_iter() .filter(|r| r.source == "user") - .map(|r| json!({"name": r.name, "expression": r.expression, "unit": r.unit, "value": r.value, "comment": r.comment, "favorite": r.favorite})) + // The `value` field keeps the number in the parameter's own unit, as the CSV + // column does, rounded for reading (#10747). + .map(|r| json!({"name": r.name, "expression": r.expression, "unit": r.unit, "value": r.display_value.or(r.value), "comment": r.comment, "favorite": r.favorite})) .collect(); serde_json::to_string_pretty(&rows).map_err(|e| bad(cmd, e.to_string()))? } @@ -501,7 +504,7 @@ fn evaluate(s: &mut Session, p: &Value) -> Result { (None, Kind::Angle) => v.to_degrees(), (None, _) => v, }; - json!({"ok": true, "value": v, "kind": k, "display_value": shown, "references": refs}) + json!({"ok": true, "value": expr::round_reported(v), "kind": k, "display_value": expr::round_reported(shown), "references": refs}) } Err(err) => json!({"ok": false, "error": err.to_string().trim_start_matches("expression: ").to_string(), "references": refs}), }; @@ -526,7 +529,8 @@ fn complete(s: &mut Session, p: &Value) -> Result { // parameters, then the others. rows.sort_by_key(|r| (!starts(&r.name), !r.favorite, r.source != "user")); for r in rows.into_iter().take(200) { - let v = r.value.map(|v| format!("{v:.4} {}", r.unit).trim().to_string()).unwrap_or_else(|| "error".into()); + // The completion shows the parameter's own unit, so it reads `display_value`. + let v = r.display_value.or(r.value).map(|v| format!("{v:.4} {}", r.unit).trim().to_string()).unwrap_or_else(|| "error".into()); let mut detail = format!("{} = {v}", r.expression); if let (Some(f), Some(i)) = (&r.feature, r.input) { detail.push_str(&format!(" ({f} {i})")); diff --git a/crates/engine/src/cmd/parameters_tests.rs b/crates/engine/src/cmd/parameters_tests.rs index 04642c6bc..e4f3b16c6 100644 --- a/crates/engine/src/cmd/parameters_tests.rs +++ b/crates/engine/src/cmd/parameters_tests.rs @@ -60,7 +60,9 @@ fn width_follows_an_expression() { run(&mut s, "parameters.change", json!({"name": "len", "expression": "5", "unit": "in"})); assert!(rel(volume(&mut s), 40.0 * 63.5 * 10.0) < 1e-9); let l = run(&mut s, "parameters.list", json!({})); - assert_eq!(row(&l, "len")["value"], 5.0, "{l}"); + // `value` is mm in every reply; the own-unit number is `display_value` (#10747). + assert_eq!(row(&l, "len")["value"], 127.0, "{l}"); + assert_eq!(row(&l, "len")["display_value"], 5.0, "{l}"); assert_eq!(row(&l, "len")["unit"], "in"); // A failing parameter fails the features using it, with its error. let e = err(&mut s, "parameters.change", json!({"name": "len", "expression": "5 deg"})); @@ -389,7 +391,8 @@ fn text_parameter_imports_accept_mixed_case_units() { assert_eq!(label["comment"], "quoted label"); assert!(label["value"].is_null()); assert_eq!(row(&list, "width")["unit"], "in"); - assert_eq!(row(&list, "width")["value"], 1.0); + assert_eq!(row(&list, "width")["value"], 25.4); + assert_eq!(row(&list, "width")["display_value"], 1.0); assert_eq!(s.doc.param_values().0["width"].v, 25.4); } // Export still uses the canonical marker and round-trips the unquoted text. @@ -933,8 +936,8 @@ fn a_parameter_added_without_a_unit_takes_the_design_unit() { let r = run(s, "parameters.add", p); (r["unit"].as_str().unwrap_or("?").to_string(), r["value"].as_f64().unwrap_or(f64::NAN), r["display_value"].as_f64().unwrap_or(f64::NAN)) }; - let close = |got: (String, f64, f64), unit: &str, mm: f64, shown: f64| { - assert!(got.0 == unit && rel(got.1, mm) < 1e-9 && rel(got.2, shown) < 1e-9, "{got:?}, expected {unit} {mm} mm ({shown})"); + let close = |got: (String, f64, f64), unit: &str, val: f64, shown: f64| { + assert!(got.0 == unit && rel(got.1, val) < 1e-9 && rel(got.2, shown) < 1e-9, "{got:?}, expected {unit} {val} ({shown})"); }; // A millimetre design is as it was. let mut s = Session::default(); @@ -951,8 +954,8 @@ fn a_parameter_added_without_a_unit_takes_the_design_unit() { // One that refers to another parameter: its bare number is an inch too. close(added(&mut s, json!({"name": "more", "expression": "v + 1"})), "in", 533.4, 21.0); close(added(&mut s, json!({"name": "half", "expression": "v / 2"})), "in", 254.0, 10.0); - // An angle stays in degrees, a unit-less count stays unit-less. - close(added(&mut s, json!({"name": "turn", "expression": "30 deg"})), "deg", 30f64.to_radians(), 30.0); + // An angle reports degrees like every other reply, a unit-less count stays unit-less. + close(added(&mut s, json!({"name": "turn", "expression": "30 deg"})), "deg", 30.0, 30.0); close(added(&mut s, json!({"name": "n", "expression": "4", "unit": ""})), "", 4.0, 4.0); close(added(&mut s, json!({"name": "twice", "expression": "n * 2"})), "", 8.0, 8.0); // parameters.change and parameters.import make a new parameter the same way. @@ -1195,3 +1198,51 @@ fn a_configuration_row_that_shrinks_a_dimensioned_line_to_a_point_is_refused() { run(&mut s, "config.activate", json!({"row": "Default"})); assert!((far_x(&s, feature) - 30.0).abs() < 1e-6); } + +/// #10747: `value` means millimetres (and degrees) in every reply — add, change and list — +/// with the parameter's own unit in `display_value`. Reported numbers carry no float noise; +/// stored values keep full precision. +#[test] +fn value_means_the_same_unit_in_every_reply() { + let mut s = Session::default(); + run(&mut s, "document.units", json!({"units": "in"})); + let a = run(&mut s, "parameters.add", json!({"name": "L", "expression": "2"})); + assert_eq!((a["value"].as_f64(), a["display_value"].as_f64()), (Some(50.8), Some(2.0)), "{a}"); + // The change reply is rounded too: 3 in is 76.2, not 76.19999999999999. + let c = run(&mut s, "parameters.change", json!({"name": "L", "expression": "3"})); + assert_eq!((c["value"].as_f64(), c["display_value"].as_f64()), (Some(76.2), Some(3.0)), "{c}"); + run(&mut s, "parameters.add", json!({"name": "d1", "expression": "L"})); + run(&mut s, "parameters.add", json!({"name": "d2", "expression": "1 in"})); + let l = run(&mut s, "parameters.list", json!({})); + // Every row's `value` is mm, whatever the parameter's own unit (#10747). + for (name, mm) in [("L", 76.2), ("d1", 76.2), ("d2", 25.4)] { + assert_eq!(row(&l, name)["value"], mm, "{name}: {l}"); + } + assert_eq!(row(&l, "L")["display_value"], 3.0, "{l}"); + assert_eq!(row(&l, "d2")["display_value"], 1.0, "{l}"); + // An angle reports degrees like every other reply, without the noise. + let a = run(&mut s, "parameters.add", json!({"name": "ang", "expression": "30 deg"})); + assert_eq!((a["value"].as_f64(), a["display_value"].as_f64()), (Some(30.0), Some(30.0)), "{a}"); + // Only what is reported is rounded: the stored value keeps full precision — the raw + // own-unit conversion still says 29.999999999999996. + let (vals, _) = s.doc.param_values(); + assert_eq!(s.doc.param_display_value(&vals, "ang"), Some(29.999999999999996), "the stored angle keeps its bits"); +} + +/// #10747: exports carry the numbers a person would read, not float noise. The `value` +/// column keeps the number in the parameter's own unit, as it always did. +#[test] +fn exports_round_reported_numbers() { + let mut s = Session::default(); + run(&mut s, "parameters.add", json!({"name": "ang", "expression": "30 deg"})); + run(&mut s, "parameters.add", json!({"name": "w", "expression": "1.2 in"})); + run(&mut s, "parameters.add", json!({"name": "s", "expression": "0.1 + 0.2"})); + let csv = run(&mut s, "parameters.export", json!({"format": "csv"}))["text"].as_str().unwrap_or_default().to_string(); + assert!(csv.contains("ang,deg,30 deg,30,,false"), "{csv}"); + assert!(csv.contains("w,mm,1.2 in,30.48,,false"), "{csv}"); + assert!(csv.contains("s,mm,0.1 + 0.2,0.3,,false"), "{csv}"); + let json_text = run(&mut s, "parameters.export", json!({"format": "json"}))["text"].as_str().unwrap_or_default().to_string(); + let rows: Vec = serde_json::from_str(&json_text).unwrap_or_default(); + let vals: Vec = rows.iter().filter_map(|r| r["value"].as_f64()).collect(); + assert_eq!(vals, vec![30.0, 30.48, 0.3], "{json_text}"); +} diff --git a/crates/ui-egui/src/params_dialog.rs b/crates/ui-egui/src/params_dialog.rs index 44df7a69f..1b2439e61 100644 --- a/crates/ui-egui/src/params_dialog.rs +++ b/crates/ui-egui/src/params_dialog.rs @@ -151,7 +151,9 @@ fn rows(app: &mut SolveApp) -> Vec { Row { expression: s(r, "expression"), unit: s(r, "unit"), - value: r.get("value").and_then(Value::as_f64), + // The dialog shows the parameter's own unit, so it reads `display_value` + // (`value` is mm / degrees in every reply, #10747). + value: r.get("display_value").and_then(Value::as_f64).or_else(|| r.get("value").and_then(Value::as_f64)), error: r.get("error").and_then(Value::as_str).map(str::to_string), comment: s(r, "comment"), favorite: r.get("favorite").and_then(Value::as_bool).unwrap_or(false), diff --git a/crates/ui-egui/src/shortcut_box.rs b/crates/ui-egui/src/shortcut_box.rs index d2276f014..b28584ce1 100644 --- a/crates/ui-egui/src/shortcut_box.rs +++ b/crates/ui-egui/src/shortcut_box.rs @@ -257,7 +257,7 @@ fn design_rows(app: &mut SolveApp, query: &str) -> Vec { .iter() .take(64) .find_map(|name| values.get(name.as_str())) - .map(|p| p.value.filter(|v| v.is_finite()).map_or_else(|| bounded(&p.expression), |v| format!("{v} {}", p.unit))) + .map(|p| p.display_value.or(p.value).filter(|v| v.is_finite()).map_or_else(|| bounded(&p.expression), |v| format!("{v} {}", p.unit))) .unwrap_or_default(); rows.push(DesignRow { label: bounded(&feature.name), @@ -268,7 +268,7 @@ fn design_rows(app: &mut SolveApp, query: &str) -> Vec { } let icon = solidcraft_engine::find_command("parameters.change").map_or("", |c| c.icon); for p in params.iter().filter(|p| p.source == "user").take(10_000) { - let value = p.value.filter(|v| v.is_finite()).map_or_else(|| bounded(&p.expression), |v| format!("{v} {}", p.unit)); + let value = p.display_value.or(p.value).filter(|v| v.is_finite()).map_or_else(|| bounded(&p.expression), |v| format!("{v} {}", p.unit)); rows.push(DesignRow { label: bounded(&p.name), detail: format!("{} · {value}", crate::i18n::tr("search.parameter")),