Skip to content

Commit

Permalink
Note decimal value in display tooltips
Browse files Browse the repository at this point in the history
- Drop Sampling display from toolbox
  • Loading branch information
Strilanc committed Sep 9, 2019
1 parent 966318c commit a4d1b99
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/draw/MathPainter.js
Original file line number Diff line number Diff line change
Expand Up @@ -622,8 +622,8 @@ class MathPainter {
let n = Math.round(Math.log2(numRows));
MathPainter.paintMatrixTooltip(painter, matrix, drawArea, focusPoints,
(c, r) => c === r ?
`Probability of |${Util.bin(c, n)}⟩` :
`Coupling of |${Util.bin(r, n)}⟩ to ⟨${Util.bin(c, n)}|`,
`Probability of |${Util.bin(c, n)} (decimal ${c})` :
`Coupling of |${Util.bin(r, n)}⟩ to ⟨${Util.bin(c, n)}| (decimal ${r} to ${c})`,
(c, r, v) => c === r ?
(matrix.cell(c, r).real*100).toFixed(4) + "%" :
matrix.cell(c, r).toString(new Format(false, 0, 6, ", ")));
Expand Down
2 changes: 1 addition & 1 deletion src/gates/AllGates.js
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ Gates.TopToolboxGroups = [
{
hint: "Displays",
gates: [
SampleDisplayFamily.ofSize(3), undefined,
undefined, undefined,
DensityMatrixDisplayFamily.ofSize(1), BlochSphereDisplay,
ProbabilityDisplayFamily.ofSize(1), AmplitudeDisplayFamily.ofSize(2)
]
Expand Down
4 changes: 2 additions & 2 deletions src/gates/AmplitudeDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,12 @@ const AMPLITUDE_DRAWER_FROM_CUSTOM_STATS = GatePainting.makeDisplayDrawer(args =
let forceSign = v => (v >= 0 ? '+' : '') + v.toFixed(2);
if (isIncoherent) {
MathPainter.paintMatrixTooltip(args.painter, matrix, drawRect, args.focusPoints,
(c, r) => `Chance of |${Util.bin(r*matrix.width() + c, args.gate.height)}⟩ [amplitude not defined]`,
(c, r) => `Chance of |${Util.bin(r*matrix.width() + c, args.gate.height)}(decimal ${r*matrix.width() + c}) [amplitude not defined]`,
(c, r, v) => `raw: ${(v.norm2()*100).toFixed(4)}%, log: ${(Math.log10(v.norm2())*10).toFixed(1)} dB`,
(c, r, v) => '[entangled with other qubits]');
} else {
MathPainter.paintMatrixTooltip(args.painter, matrix, drawRect, args.focusPoints,
(c, r) => `Amplitude of |${Util.bin(r*matrix.width() + c, args.gate.height)}⟩`,
(c, r) => `Amplitude of |${Util.bin(r*matrix.width() + c, args.gate.height)} (decimal ${r*matrix.width() + c})`,
(c, r, v) => 'val:' + v.toString(new Format(false, 0, 5, ", ")),
(c, r, v) => `mag²:${(v.norm2()*100).toFixed(4)}%, phase:${forceSign(v.phase() * 180 / Math.PI)}°`);
if (phaseLockIndex !== undefined) {
Expand Down
2 changes: 1 addition & 1 deletion src/gates/ProbabilityDisplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function _paintMultiProbabilityDisplay_tooltips(args) {
painter,
x + w,
y + k * d,
`Chance of |${Util.bin(k, args.gate.height)}⟩ if measured`,
`Chance of |${Util.bin(k, args.gate.height)}(decimal ${k}) if measured`,
'raw: ' + (p * 100).toFixed(4) + "%",
'log: ' + (Math.log10(p) * 10).toFixed(1) + " dB");
}
Expand Down
2 changes: 1 addition & 1 deletion src/ui/DisplayedCircuit.js
Original file line number Diff line number Diff line change
Expand Up @@ -1341,7 +1341,7 @@ class DisplayedCircuit {
Config.SUPERPOSITION_BACK_COLOR);
let forceSign = v => (v >= 0 ? '+' : '') + v.toFixed(2);
MathPainter.paintMatrixTooltip(painter, amplitudeGrid, gridRect, hand.hoverPoints(),
(c, r) => `Amplitude of |${Util.bin(r*amplitudeGrid.width() + c, numWire)}⟩`,
(c, r) => `Amplitude of |${Util.bin(r*amplitudeGrid.width() + c, numWire)} (decimal ${r*amplitudeGrid.width() + c})`,
(c, r, v) => 'val:' + v.toString(new Format(false, 0, 5, ", ")),
(c, r, v) => `mag²:${(v.norm2()*100).toFixed(4)}%, phase:${forceSign(v.phase() * 180 / Math.PI)}°`);

Expand Down

0 comments on commit a4d1b99

Please sign in to comment.