Skip to content

Commit

Permalink
Merge pull request #203 from flatironinstitute/draws_table_wrapping
Browse files Browse the repository at this point in the history
Improve formatting of draws table
  • Loading branch information
WardBrian authored Aug 6, 2024
2 parents bd51afd + ec34271 commit ba3756f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
11 changes: 9 additions & 2 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 formattedDraws = 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,7 +175,7 @@ const DrawsView: FunctionComponent<DrawsViewProps> = ({
<tr key={i}>
<td>{drawChainIds[i]}</td>
<td>{drawNumbers[i]}</td>
{draws.map((draw, j) => (
{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
1 change: 1 addition & 0 deletions gui/src/draws-table.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
.draws-table th,
.draws-table td {
padding: 2px 2px;
white-space: nowrap;
}

.draws-table tbody tr {
Expand Down

0 comments on commit ba3756f

Please sign in to comment.