Skip to content

Commit 0127ec0

Browse files
authored
Add remaining single qubit Clifford gates (#895)
Add the last 9 (out of 24) single qubit Clifford gates that weren't defined by stim until now: - Add `C_NXYZ` gate - Add `C_XNYZ` gate - Add `C_XYNZ` gate - Add `C_NZYX` gate - Add `C_ZNYX` gate - Add `C_ZYNX` gate - Add `H_NXY` gate - Add `H_NXZ` gate - Add `H_NYZ` gate Also add some useful placeholder gates for the tag-obsessed to use: - Add `I_ERROR` gate - Add `II_ERROR` gate - Add `II` gate And finally some compatibility changes: - Modify crumble to replace feedback gates with "ERR" gates, instead of silently removing them - Generalize crumble's 'k+#' automark functionality to work with multi-qubit measurements - Modify stimcirq to turn all `cirq.SingleQubitCliffordGate` instances into a single gate, instead of ever using multiple gates Fixes #885 Fixes #855
1 parent d14835f commit 0127ec0

File tree

78 files changed

+3037
-710
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+3037
-710
lines changed

dev/canvas_with_texture_for_3d_diagrams.html

+59-33
Original file line numberDiff line numberDiff line change
@@ -49,47 +49,60 @@
4949
[sub, sup] = sub.split("^");
5050
}
5151
let vert = Math.max(sub.length, sup.length, main.length) >= 3 && sub.length > 0;
52-
let fontSize = 18;
53-
while (fontSize > 6) {
54-
let bigFont = fontSize + 'pt serif';
55-
let smallFont = (fontSize * 0.75) + 'pt serif';
52+
let bigFontSize = 18;
53+
let smallFontSize = 18 * 0.75;
54+
while (bigFontSize > 6) {
55+
let bigFont = bigFontSize + 'pt serif';
56+
let smallFont = (smallFontSize * 0.75) + 'pt serif';
5657
ctx.font = bigFont;
5758
let w_main = ctx.measureText(main).width;
5859
ctx.font = smallFont;
5960
let w_sub = ctx.measureText(sub).width;
6061
let w_sup = ctx.measureText(sup).width;
6162
let w_subsup = Math.max(ctx.measureText(sub).width, ctx.measureText(sup).width);
62-
let w_total = vert ? Math.max(w_main, w_subsup) : w_main + w_subsup;
63-
if (w_total < 32) {
64-
if (vert) {
65-
let dy = 0;
66-
if (w_sub < w_main * 0.8) {
67-
smallFont = bigFont;
68-
dy = -2;
69-
}
70-
ctx.fillStyle = stroke;
71-
ctx.font = bigFont;
72-
ctx.textBaseline = 'middle'
73-
ctx.fillText(main, x * 32 + 16 - w_main / 2, y * 32 + 11);
74-
ctx.font = smallFont;
75-
ctx.textBaseline = 'bottom';
76-
ctx.fillText(sub, x * 32 + 16 - w_sub / 2, y * 32 + 34 + dy);
77-
ctx.textBaseline = 'hanging';
78-
ctx.fillText(sup, x * 32 + 16 - w_sup / 2, y * 32);
79-
} else {
80-
ctx.fillStyle = stroke;
81-
ctx.font = bigFont;
82-
ctx.textBaseline = 'middle'
83-
ctx.fillText(main, x * 32 + 16 - w_main / 2 - w_subsup / 2, y * 32 + 18);
84-
ctx.font = smallFont;
85-
ctx.textBaseline = 'bottom';
86-
ctx.fillText(sub, x * 32 + 16 + w_main / 2 - w_sub / 2, y * 32 + (sup !== "" ? 34 : 32));
87-
ctx.textBaseline = 'hanging';
88-
ctx.fillText(sup, x * 32 + 16 + w_main / 2 - w_sup / 2, y * 32);
63+
if (vert) {
64+
if (w_main > 32) {
65+
bigFontSize -= 1;
66+
smallFontSize -= 0.75;
67+
continue;
68+
} else if (w_subsup > 32) {
69+
smallFontSize -= 0.75;
70+
continue;
8971
}
90-
break;
72+
} else {
73+
if (w_main + w_subsup > 32) {
74+
bigFontSize -= 1;
75+
smallFontSize -= 0.75;
76+
continue;
77+
}
78+
}
79+
if (vert) {
80+
let dy = 0;
81+
if (w_sub < w_main * 0.8) {
82+
smallFont = bigFont;
83+
dy = -2;
84+
}
85+
ctx.fillStyle = stroke;
86+
ctx.font = bigFont;
87+
ctx.textBaseline = 'middle'
88+
ctx.fillText(main, x * 32 + 16 - w_main / 2, y * 32 + 11);
89+
ctx.font = smallFont;
90+
ctx.textBaseline = 'bottom';
91+
ctx.fillText(sub, x * 32 + 16 - w_sub / 2, y * 32 + 34 + dy);
92+
ctx.textBaseline = 'hanging';
93+
ctx.fillText(sup, x * 32 + 16 - w_sup / 2, y * 32);
94+
} else {
95+
ctx.fillStyle = stroke;
96+
ctx.font = bigFont;
97+
ctx.textBaseline = 'middle'
98+
ctx.fillText(main, x * 32 + 16 - w_main / 2 - w_subsup / 2, y * 32 + 18);
99+
ctx.font = smallFont;
100+
ctx.textBaseline = 'bottom';
101+
ctx.fillText(sub, x * 32 + 16 + w_main / 2 - w_sub / 2, y * 32 + (sup !== "" ? 34 : 32));
102+
ctx.textBaseline = 'hanging';
103+
ctx.fillText(sup, x * 32 + 16 + w_main / 2 - w_sup / 2, y * 32);
91104
}
92-
fontSize--;
105+
break;
93106
}
94107
}
95108

@@ -197,6 +210,8 @@
197210
drawRect(ctx, "sweep_X", "#FEE", "#000", n++);
198211
drawRect(ctx, "sweep_Y", "#EFE", "#000", n++);
199212
drawRect(ctx, "sweep_Z", "#EEF", "#000", n++);
213+
n += 2;
214+
drawRect(ctx, "I_ERR", "#FFF", "#000", n++);
200215

201216
n = 128 + 16;
202217
drawRect(ctx, "I", "#FFF", "#000", n++);
@@ -223,6 +238,16 @@
223238
drawRect(ctx, "SPP_X†", "#F44", "#000", n++);
224239
drawRect(ctx, "SPP_Y†", "#4F4", "#000", n++);
225240
drawRect(ctx, "SPP_Z†", "#44F", "#000", n++);
241+
drawRect(ctx, "C_NXYZ", "#FFA", "#000", n++);
242+
drawRect(ctx, "C_XNYZ", "#FFA", "#000", n++);
243+
drawRect(ctx, "C_XYNZ", "#FFA", "#000", n++);
244+
drawRect(ctx, "C_NZYX", "#AFF", "#000", n++);
245+
drawRect(ctx, "C_ZNYX", "#AFF", "#000", n++);
246+
drawRect(ctx, "C_ZYNX", "#AFF", "#000", n++);
247+
drawRect(ctx, "H_NXY", "#FAA", "#000", n++);
248+
drawRect(ctx, "H_NXZ", "#AFA", "#000", n++);
249+
drawRect(ctx, "H_NYZ", "#AAF", "#000", n++);
250+
drawRect(ctx, "II", "#FFF", "#000", n++);
226251

227252
n = 128 + 48;
228253
drawCpp(ctx, 'I', 'X', n++);
@@ -240,6 +265,7 @@
240265
drawCpp(ctx, 'Z', 'X', n++);
241266
drawCpp(ctx, 'Z', 'Y', n++);
242267
drawCpp(ctx, 'Z', 'Z', n++);
268+
drawRect(ctx, "II_ERR", "#FFF", "#000", n++);
243269
}
244270

245271
draw(document.getElementById('cv').getContext('2d'))

dev/doctest_proper.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def main():
9494
continue
9595
v = v.__doc__.lower()
9696
if '\n' in v.strip() and 'examples:' not in v and 'example:' not in v and '[deprecated]' not in v:
97-
if k.split('.')[-1] not in ['__next__', '__iter__', '__init_subclass__', '__module__', '__eq__', '__ne__', '__str__', '__repr__']:
97+
if k.split('.')[-1] not in ['__format__', '__next__', '__iter__', '__init_subclass__', '__module__', '__eq__', '__ne__', '__str__', '__repr__']:
9898
if all(not (e.startswith('_') and not e.startswith('__')) for e in k.split('.')):
9999
print(f" Warning: Missing 'examples:' section in docstring of {k!r}", file=sys.stderr)
100100

0 commit comments

Comments
 (0)