From ec3427158e7a592a7c80ac1036737eb3ebff63a1 Mon Sep 17 00:00:00 2001 From: Brian Ward Date: Tue, 6 Aug 2024 13:50:20 +0000 Subject: [PATCH] Fix formatting of integer columns --- gui/src/app/SamplerOutputView/SamplerOutputView.tsx | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gui/src/app/SamplerOutputView/SamplerOutputView.tsx b/gui/src/app/SamplerOutputView/SamplerOutputView.tsx index 5e12534..5e8dbb2 100644 --- a/gui/src/app/SamplerOutputView/SamplerOutputView.tsx +++ b/gui/src/app/SamplerOutputView/SamplerOutputView.tsx @@ -108,7 +108,9 @@ const DrawsView: FunctionComponent = ({ >(300); const draws2 = useMemo(() => { if (abbreviatedToNumRows === undefined) return draws; - return draws.map((draw) => draw.slice(0, abbreviatedToNumRows)); + return draws.map((draw) => + formatDraws(draw.slice(0, abbreviatedToNumRows)), + ); }, [draws, abbreviatedToNumRows]); const handleExportToCsv = useCallback(() => { const csvText = prepareCsvText( @@ -173,8 +175,8 @@ const DrawsView: FunctionComponent = ({ {drawChainIds[i]} {drawNumbers[i]} - {draws.map((draw, j) => ( - {draw[i].toPrecision(6)} + {draws2.map((draw, j) => ( + {draw[i]} ))} ))} @@ -196,6 +198,11 @@ const DrawsView: FunctionComponent = ({ ); }; +const formatDraws = (draws: number[]) => { + if (draws.every((x) => Number.isInteger(x))) return draws; + return draws.map((x) => x.toPrecision(6)); +}; + const prepareCsvText = ( draws: number[][], paramNames: string[],