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

Add remaining single qubit Clifford gates #895

Merged
merged 10 commits into from
Mar 4, 2025
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
92 changes: 59 additions & 33 deletions dev/canvas_with_texture_for_3d_diagrams.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,47 +49,60 @@
[sub, sup] = sub.split("^");
}
let vert = Math.max(sub.length, sup.length, main.length) >= 3 && sub.length > 0;
let fontSize = 18;
while (fontSize > 6) {
let bigFont = fontSize + 'pt serif';
let smallFont = (fontSize * 0.75) + 'pt serif';
let bigFontSize = 18;
let smallFontSize = 18 * 0.75;
while (bigFontSize > 6) {
let bigFont = bigFontSize + 'pt serif';
let smallFont = (smallFontSize * 0.75) + 'pt serif';
ctx.font = bigFont;
let w_main = ctx.measureText(main).width;
ctx.font = smallFont;
let w_sub = ctx.measureText(sub).width;
let w_sup = ctx.measureText(sup).width;
let w_subsup = Math.max(ctx.measureText(sub).width, ctx.measureText(sup).width);
let w_total = vert ? Math.max(w_main, w_subsup) : w_main + w_subsup;
if (w_total < 32) {
if (vert) {
let dy = 0;
if (w_sub < w_main * 0.8) {
smallFont = bigFont;
dy = -2;
}
ctx.fillStyle = stroke;
ctx.font = bigFont;
ctx.textBaseline = 'middle'
ctx.fillText(main, x * 32 + 16 - w_main / 2, y * 32 + 11);
ctx.font = smallFont;
ctx.textBaseline = 'bottom';
ctx.fillText(sub, x * 32 + 16 - w_sub / 2, y * 32 + 34 + dy);
ctx.textBaseline = 'hanging';
ctx.fillText(sup, x * 32 + 16 - w_sup / 2, y * 32);
} else {
ctx.fillStyle = stroke;
ctx.font = bigFont;
ctx.textBaseline = 'middle'
ctx.fillText(main, x * 32 + 16 - w_main / 2 - w_subsup / 2, y * 32 + 18);
ctx.font = smallFont;
ctx.textBaseline = 'bottom';
ctx.fillText(sub, x * 32 + 16 + w_main / 2 - w_sub / 2, y * 32 + (sup !== "" ? 34 : 32));
ctx.textBaseline = 'hanging';
ctx.fillText(sup, x * 32 + 16 + w_main / 2 - w_sup / 2, y * 32);
if (vert) {
if (w_main > 32) {
bigFontSize -= 1;
smallFontSize -= 0.75;
continue;
} else if (w_subsup > 32) {
smallFontSize -= 0.75;
continue;
}
break;
} else {
if (w_main + w_subsup > 32) {
bigFontSize -= 1;
smallFontSize -= 0.75;
continue;
}
}
if (vert) {
let dy = 0;
if (w_sub < w_main * 0.8) {
smallFont = bigFont;
dy = -2;
}
ctx.fillStyle = stroke;
ctx.font = bigFont;
ctx.textBaseline = 'middle'
ctx.fillText(main, x * 32 + 16 - w_main / 2, y * 32 + 11);
ctx.font = smallFont;
ctx.textBaseline = 'bottom';
ctx.fillText(sub, x * 32 + 16 - w_sub / 2, y * 32 + 34 + dy);
ctx.textBaseline = 'hanging';
ctx.fillText(sup, x * 32 + 16 - w_sup / 2, y * 32);
} else {
ctx.fillStyle = stroke;
ctx.font = bigFont;
ctx.textBaseline = 'middle'
ctx.fillText(main, x * 32 + 16 - w_main / 2 - w_subsup / 2, y * 32 + 18);
ctx.font = smallFont;
ctx.textBaseline = 'bottom';
ctx.fillText(sub, x * 32 + 16 + w_main / 2 - w_sub / 2, y * 32 + (sup !== "" ? 34 : 32));
ctx.textBaseline = 'hanging';
ctx.fillText(sup, x * 32 + 16 + w_main / 2 - w_sup / 2, y * 32);
}
fontSize--;
break;
}
}

Expand Down Expand Up @@ -197,6 +210,8 @@
drawRect(ctx, "sweep_X", "#FEE", "#000", n++);
drawRect(ctx, "sweep_Y", "#EFE", "#000", n++);
drawRect(ctx, "sweep_Z", "#EEF", "#000", n++);
n += 2;
drawRect(ctx, "I_ERR", "#FFF", "#000", n++);

n = 128 + 16;
drawRect(ctx, "I", "#FFF", "#000", n++);
Expand All @@ -223,6 +238,16 @@
drawRect(ctx, "SPP_X†", "#F44", "#000", n++);
drawRect(ctx, "SPP_Y†", "#4F4", "#000", n++);
drawRect(ctx, "SPP_Z†", "#44F", "#000", n++);
drawRect(ctx, "C_NXYZ", "#FFA", "#000", n++);
drawRect(ctx, "C_XNYZ", "#FFA", "#000", n++);
drawRect(ctx, "C_XYNZ", "#FFA", "#000", n++);
drawRect(ctx, "C_NZYX", "#AFF", "#000", n++);
drawRect(ctx, "C_ZNYX", "#AFF", "#000", n++);
drawRect(ctx, "C_ZYNX", "#AFF", "#000", n++);
drawRect(ctx, "H_NXY", "#FAA", "#000", n++);
drawRect(ctx, "H_NXZ", "#AFA", "#000", n++);
drawRect(ctx, "H_NYZ", "#AAF", "#000", n++);
drawRect(ctx, "II", "#FFF", "#000", n++);

n = 128 + 48;
drawCpp(ctx, 'I', 'X', n++);
Expand All @@ -240,6 +265,7 @@
drawCpp(ctx, 'Z', 'X', n++);
drawCpp(ctx, 'Z', 'Y', n++);
drawCpp(ctx, 'Z', 'Z', n++);
drawRect(ctx, "II_ERR", "#FFF", "#000", n++);
}

draw(document.getElementById('cv').getContext('2d'))
Expand Down
2 changes: 1 addition & 1 deletion dev/doctest_proper.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def main():
continue
v = v.__doc__.lower()
if '\n' in v.strip() and 'examples:' not in v and 'example:' not in v and '[deprecated]' not in v:
if k.split('.')[-1] not in ['__next__', '__iter__', '__init_subclass__', '__module__', '__eq__', '__ne__', '__str__', '__repr__']:
if k.split('.')[-1] not in ['__format__', '__next__', '__iter__', '__init_subclass__', '__module__', '__eq__', '__ne__', '__str__', '__repr__']:
if all(not (e.startswith('_') and not e.startswith('__')) for e in k.split('.')):
print(f" Warning: Missing 'examples:' section in docstring of {k!r}", file=sys.stderr)

Expand Down
Loading
Loading