Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve formatting of draws table #203

Merged
merged 2 commits into from
Aug 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 draws2 = useMemo(() => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As long as you're changing things, might as well make this more semantic--formattedDraws or the like?

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