Land quantum Q4 visuals and gate Stream to LLM/agent imports.
Add probs/Bloch draw kinds and matches_matrix, plus feature docs; hide the view Stream panel unless llm/agent is imported, and stop rewriting method names like 绘图 through host_plot aliases. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
25b7be6739
commit
eea6fe1a0e
20 files changed
+852
-23
No files matched your search
@@ -0,0 +1,33 @@
|
||||
---
|
||||
title: quantum draw probs/bloch smoke
|
||||
description: draw kind=probs and kind=bloch return matching kind tags.
|
||||
> ext/quantum/quantum.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
`steps` =
|
||||
|
||||
| step | gate | qubits |
|
||||
|------|------|--------|
|
||||
| 1 | H | 0 |
|
||||
| 2 | CX | 0,1 |
|
||||
|
||||
*`qc` = > quantum.circuit qubits=2 steps=`steps` *
|
||||
*`img` = > `qc`.draw kind=probs path=quantum-draw-probs.svg *
|
||||
*`kind` = `img`[^kind] *
|
||||
|
||||
1. `kind` == probs
|
||||
> print text=probs-ok
|
||||
2. *
|
||||
> print text=probs-fail
|
||||
|
||||
*`qc1` = > quantum.circuit qubits=1 *
|
||||
*`qc1` = > `qc1`.h qubit=0 *
|
||||
*`bloch` = > `qc1`.draw kind=bloch path=quantum-draw-bloch.svg *
|
||||
*`bk` = `bloch`[^kind] *
|
||||
|
||||
1. `bk` == bloch
|
||||
> print text=bloch-ok
|
||||
2. *
|
||||
> print text=bloch-fail
|
||||
@@ -0,0 +1,25 @@
|
||||
---
|
||||
title: quantum gate matches_matrix smoke
|
||||
description: Named H matches an explicit 2x2 nested list.
|
||||
> ext/quantum/quantum.mq.md
|
||||
> lib/json.mq.md
|
||||
---
|
||||
|
||||
# main
|
||||
|
||||
*`H_matrix` = > json.parse text=[[0.7071067811865475,0.7071067811865475],[0.7071067811865475,-0.7071067811865475]] *
|
||||
*`H` = > quantum.gate name=H *
|
||||
*`ok` = > `H`.matches_matrix matrix=`H_matrix` *
|
||||
|
||||
1. `ok`
|
||||
> print text=match-ok
|
||||
2. *
|
||||
> print text=match-fail
|
||||
|
||||
*`bad` = > json.parse text=[[1,0],[0,1]] *
|
||||
*`no` = > `H`.matches_matrix matrix=`bad` *
|
||||
|
||||
1. not `no`
|
||||
> print text=reject-ok
|
||||
2. *
|
||||
> print text=reject-fail
|
||||
@@ -1493,6 +1493,39 @@ fn ext_quantum_steps_smoke() {
|
||||
let _ = std::fs::remove_file(svg_path);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_quantum_draw_smoke() {
|
||||
let status = Command::new("cargo")
|
||||
.args(["build", "-p", "marqdo_plugin_quantum"])
|
||||
.current_dir(env!("CARGO_MANIFEST_DIR"))
|
||||
.status()
|
||||
.expect("build quantum plugin");
|
||||
assert!(status.success(), "failed to build marqdo_plugin_quantum");
|
||||
assert_out("tests/ext/quantum-draw-smoke.mq.md", "probs-ok\nbloch-ok");
|
||||
for p in [
|
||||
"tests/ext/quantum-draw-probs.svg",
|
||||
"tests/ext/quantum-draw-bloch.svg",
|
||||
] {
|
||||
let svg = std::fs::read_to_string(p).unwrap_or_default();
|
||||
assert!(svg.contains("<svg"), "expected svg at {p}");
|
||||
let _ = std::fs::remove_file(p);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_quantum_gate_matrix_smoke() {
|
||||
let status = Command::new("cargo")
|
||||
.args(["build", "-p", "marqdo_plugin_quantum"])
|
||||
.current_dir(env!("CARGO_MANIFEST_DIR"))
|
||||
.status()
|
||||
.expect("build quantum plugin");
|
||||
assert!(status.success(), "failed to build marqdo_plugin_quantum");
|
||||
assert_out(
|
||||
"tests/ext/quantum-gate-matrix-smoke.mq.md",
|
||||
"match-ok\nreject-ok",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ext_agent_framework_smoke() {
|
||||
let status = Command::new("cargo")
|
||||
|
||||
Reference in new issue
Block a user