From f34207c8d8b33d2058ed18686a936575f0ac02ef Mon Sep 17 00:00:00 2001 From: salman Date: Thu, 19 Nov 2026 13:37:48 +0100 Subject: [PATCH] Format suggestion metadata concisely --- muSRFitlib.js | 16 ++++++++++++---- tests/model-recommendation.test.js | 1 + 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/muSRFitlib.js b/muSRFitlib.js index dcbc541..7b73e69 100644 --- a/muSRFitlib.js +++ b/muSRFitlib.js @@ -7396,10 +7396,18 @@ async function showModelSuggestions() let temperature = input.conditions.temperature; let energy = input.conditions.energy; let spinRotator = input.measurement.spin_rotator; - if (temperature) contextValues.push("temperature " + temperature.value + " K"); - if (field) contextValues.push("field " + field.value + " G"); - if (energy) contextValues.push("energy " + energy.value + " keV"); - if (spinRotator) contextValues.push("spin orientation " + spinRotator.value + " deg"); + let contextNumberFormat = new Intl.NumberFormat(undefined, { + maximumSignificantDigits: 2, + useGrouping: false + }); + if (temperature) { + contextValues.push("temperature " + contextNumberFormat.format(temperature.value) + " K"); + } + if (field) contextValues.push("field " + contextNumberFormat.format(field.value) + " G"); + if (energy) contextValues.push("energy " + contextNumberFormat.format(energy.value) + " keV"); + if (spinRotator) { + contextValues.push("spin orientation " + contextNumberFormat.format(spinRotator.value) + " deg"); + } contextElement.textContent = "Using " + (input.instrument || "unknown instrument") + ", " + input.n_runs + " generated RUN block" + (input.n_runs === 1 ? "" : "s") + (contextValues.length ? ", " + contextValues.join(", ") diff --git a/tests/model-recommendation.test.js b/tests/model-recommendation.test.js index fa3f97d..164bbd2 100644 --- a/tests/model-recommendation.test.js +++ b/tests/model-recommendation.test.js @@ -185,6 +185,7 @@ function testMarkupContract() { assert.match(source, /Reading run metadata\.\.\./); assert.match(source, /Run metadata unavailable:/); assert.match(source, /await initializeLocalRunData\(\)/); + assert.match(source, /maximumSignificantDigits:\s*2/); } auditScrubbedIndex();