Skip to content

Commit

Permalink
DumpMachine in playground should display message when no qubits are…
Browse files Browse the repository at this point in the history
… allocated

Fixes #1962
  • Loading branch information
swernli committed Oct 31, 2024
1 parent 0c5ae2c commit 4425ae0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
1 change: 1 addition & 0 deletions playground/src/results.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ export function ResultsTab(props: {
<StateTable
dump={evt.state}
latexDump={evt.stateLatex}
count={evt.qubitCount}
></StateTable>
</div>
) : (
Expand Down
29 changes: 28 additions & 1 deletion playground/src/state.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,34 @@ function formatComplex(real: number, imag: number) {
return `${r}${i}`;
}

export function StateTable(props: { dump: Dump; latexDump: string | null }) {
export function StateTable(props: {
dump: Dump;
latexDump: string | null;
count: number;
}) {
if (props.count === 0) {
return (
<div>
<table class="state-table">
<thead>
<tr>
<th>Basis State</th>
<th>Amplitude</th>
<th>Measurement Probability</th>
<th colSpan={2}>Phase</th>
</tr>
</thead>
<tbody>
<tr>
<td>No qubits allocated</td>
</tr>
</tbody>
</table>
<br></br>
</div>
);
}

return (
<div>
<table class="state-table">
Expand Down

0 comments on commit 4425ae0

Please sign in to comment.