Skip to content

Commit

Permalink
Fix formatting of integer columns
Browse files Browse the repository at this point in the history
  • Loading branch information
WardBrian committed Aug 6, 2024
1 parent 38882ea commit ec34271
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions gui/src/app/SamplerOutputView/SamplerOutputView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ const DrawsView: FunctionComponent<DrawsViewProps> = ({
>(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(
Expand Down Expand Up @@ -173,8 +175,8 @@ const DrawsView: FunctionComponent<DrawsViewProps> = ({
<tr key={i}>
<td>{drawChainIds[i]}</td>
<td>{drawNumbers[i]}</td>
{draws.map((draw, j) => (
<td key={j}>{draw[i].toPrecision(6)}</td>
{draws2.map((draw, j) => (
<td key={j}>{draw[i]}</td>
))}
</tr>
))}
Expand All @@ -196,6 +198,11 @@ const DrawsView: FunctionComponent<DrawsViewProps> = ({
);
};

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[],
Expand Down

0 comments on commit ec34271

Please sign in to comment.