qubasic 0.6.4__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. {qubasic-0.6.4 → qubasic-0.7.0}/CHANGELOG.md +17 -0
  2. {qubasic-0.6.4/qubasic.egg-info → qubasic-0.7.0}/PKG-INFO +75 -1
  3. {qubasic-0.6.4 → qubasic-0.7.0}/README.md +74 -0
  4. {qubasic-0.6.4 → qubasic-0.7.0}/pyproject.toml +1 -1
  5. {qubasic-0.6.4 → qubasic-0.7.0/qubasic.egg-info}/PKG-INFO +75 -1
  6. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic.egg-info/SOURCES.txt +1 -0
  7. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/__init__.py +1 -1
  8. qubasic-0.7.0/qubasic_core/algorithms.py +428 -0
  9. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/analysis.py +94 -0
  10. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/display.py +5 -3
  11. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/engine_state.py +1 -0
  12. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/executor.py +62 -0
  13. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/file_io.py +157 -1
  14. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/memory.py +6 -4
  15. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/qol.py +3 -0
  16. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/terminal.py +172 -13
  17. {qubasic-0.6.4 → qubasic-0.7.0}/tests/test_features.py +25 -0
  18. {qubasic-0.6.4 → qubasic-0.7.0}/tests/test_qubasic.py +137 -7
  19. {qubasic-0.6.4 → qubasic-0.7.0}/LICENSE +0 -0
  20. {qubasic-0.6.4 → qubasic-0.7.0}/MANIFEST.in +0 -0
  21. {qubasic-0.6.4 → qubasic-0.7.0}/examples/bell.qb +0 -0
  22. {qubasic-0.6.4 → qubasic-0.7.0}/examples/grover3.qb +0 -0
  23. {qubasic-0.6.4 → qubasic-0.7.0}/examples/locc_teleport.qb +0 -0
  24. {qubasic-0.6.4 → qubasic-0.7.0}/examples/sweep_rx.qb +0 -0
  25. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic.egg-info/dependency_links.txt +0 -0
  26. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic.egg-info/entry_points.txt +0 -0
  27. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic.egg-info/requires.txt +0 -0
  28. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic.egg-info/top_level.txt +0 -0
  29. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/__main__.py +0 -0
  30. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/backend.py +0 -0
  31. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/classic.py +0 -0
  32. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/cli.py +0 -0
  33. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/control_flow.py +0 -0
  34. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/debug.py +0 -0
  35. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/demos.py +0 -0
  36. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/engine.py +0 -0
  37. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/errors.py +0 -0
  38. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/exec_context.py +0 -0
  39. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/expression.py +0 -0
  40. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/gates.py +0 -0
  41. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/help_text.py +0 -0
  42. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/io_protocol.py +0 -0
  43. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/locc.py +0 -0
  44. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/locc_commands.py +0 -0
  45. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/locc_display.py +0 -0
  46. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/locc_engine.py +0 -0
  47. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/locc_execution.py +0 -0
  48. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/mock_backend.py +0 -0
  49. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/noise_mixin.py +0 -0
  50. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/parser.py +0 -0
  51. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/patterns.py +0 -0
  52. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/profiler.py +0 -0
  53. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/program_mgmt.py +0 -0
  54. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/protocol.py +0 -0
  55. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/scope.py +0 -0
  56. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/screen.py +0 -0
  57. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/state_display.py +0 -0
  58. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/statements.py +0 -0
  59. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/strings.py +0 -0
  60. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/subs.py +0 -0
  61. {qubasic-0.6.4 → qubasic-0.7.0}/qubasic_core/sweep.py +0 -0
  62. {qubasic-0.6.4 → qubasic-0.7.0}/setup.cfg +0 -0
@@ -1,5 +1,22 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.7.0 (2026-06-19)
4
+
5
+ ### Added
6
+ - Dynamic circuits in the standard Aer path: `MEAS q -> c` is a real mid-circuit measurement and `IF c THEN <gate>` (also `IF c == 0`, `NOT c`, and `ELSE`) compiles to a Qiskit `if_test`, so feedforward corrections run on the actual outcome without LOCC mode. The mid-circuit measurement registers are kept out of the reported histogram.
7
+ - Algorithm primitives applied to a qubit range: `QFT`/`IQFT`, `DIFFUSE` (Grover diffusion), `MCX`/`MCZ`/`MCP` (arbitrary control count), `QADD`/`QADDC` (in-place register and constant addition mod 2^n), and `QPE` (phase estimation of a UNITARY). The QFT is least-significant-first (qubit 0 = low bit) so register reads are consistent.
8
+ - Optimization drivers: `MINIMIZE v1, v2 -> <cost expr>` runs a dependency-free Nelder-Mead optimizer over circuit parameters (VQE/QAOA), and `GRADIENT` computes the parameter-shift gradient. The cost is any expression evaluated after each run from variables the program sets (for example via `SAVE_EXPECT`).
9
+ - Device model for transpilation: `COUPLING linear|ring|full|<edges>` constrains two-qubit connectivity and `BASIS <gates>` restricts to a native gate set, both offline; RUN reports the routed depth and SWAP count.
10
+ - `FIDELITY <target>` (state fidelity against a named state or amplitude list) and `TOMOGRAPHY [shots]` (density-matrix reconstruction from Pauli expectations, exact or shot-sampled).
11
+ - `LOADQASM <file>` imports OpenQASM as an editable program (2.0 built-in; 3.0 requires the optional `qiskit_qasm3_import` package).
12
+ - `SET_DENSITY [[...]]` injects a mixed state (density matrix) for the next run, using the density_matrix method.
13
+ - `SAVEPNG <file> hist|bloch|circuit` saves a plot as a PNG (requires matplotlib; circuit diagrams also need pylatexenc).
14
+
15
+ ## 0.6.5 (2026-06-19)
16
+
17
+ ### Fixed
18
+ - The Bloch sphere Y component had an inverted sign, so a qubit in |+i> was reported at -Y (and |-i> at +Y). `BLOCH`, `DRAW`, `PRINT QUBIT(n)`, and the memory-mapped Bloch-Y field (`$0100 + q*8 + 2`) were all affected, and `BLOCH` mislabeled |+i> as "|-i>". X and Z were already correct. Y now matches the standard convention (`<Y> = +2 Im(<1|rho|0>)`), verified against Qiskit expectation values.
19
+
3
20
  ## 0.6.4 (2026-06-19)
4
21
 
5
22
  ### Fixed
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qubasic
3
- Version: 0.6.4
3
+ Version: 0.7.0
4
4
  Summary: Quantum BASIC Interactive Terminal
5
5
  Author-email: "Charles C. Norton" <machineelv@gmail.com>
6
6
  License-Expression: MIT
@@ -417,6 +417,80 @@ STATS SHOW Show mean/stddev/min/max per state
417
417
  STATS CLEAR Reset accumulator
418
418
  ```
419
419
 
420
+ ### State comparison
421
+ ```
422
+ FIDELITY |BELL> State fidelity |<target|psi>|^2 vs a named state
423
+ FIDELITY [0.707,0,0,0.707] ...or an explicit amplitude list
424
+ TOMOGRAPHY Reconstruct the density matrix from Pauli expectations
425
+ TOMOGRAPHY 2000 Statistical tomography (2000 shots per Pauli basis)
426
+ ```
427
+
428
+ ## Algorithm primitives
429
+
430
+ Composable building blocks applied to a qubit range (`lo-hi`, a list, or all
431
+ qubits). Qiskit-path only.
432
+
433
+ ```
434
+ QFT 0-3 Quantum Fourier transform over qubits 0..3
435
+ IQFT 0-3 Inverse QFT
436
+ DIFFUSE 0-2 Grover diffusion operator (2|s><s| - I)
437
+ MCX 0,1,2, 3 Multi-controlled X (any number of controls, last = target)
438
+ MCZ 0,1,2 Multi-controlled Z
439
+ MCP theta, 0,1, 2 Multi-controlled phase
440
+ QADD 0-2, 3-5 In-place register add: A += B (mod 2^n), qubit 0 = LSB
441
+ QADDC 5, 0-2 In-place constant add: A += 5 (mod 2^n)
442
+ QPE 0-3 4 UGATE Phase estimation of a UNITARY on a target register
443
+ ```
444
+
445
+ ## Optimization
446
+
447
+ Classical drivers over circuit parameters (VQE/QAOA). Build a parametrized
448
+ ansatz, compute a cost with `SAVE_EXPECT`, then minimize it.
449
+
450
+ ```
451
+ 10 RY theta, 0
452
+ 20 SAVE_EXPECT Z 0 -> cost
453
+ MINIMIZE theta -> cost Nelder-Mead minimization (dependency-free)
454
+ MINIMIZE a, b -> z0 + 0.5*z1 ITERS 200 Multi-parameter; cost is any post-run expression
455
+ GRADIENT theta -> cost Parameter-shift gradient d(cost)/d(theta)
456
+ ```
457
+
458
+ ## Dynamic circuits (feedforward)
459
+
460
+ In standard mode, `MEAS` is a real mid-circuit measurement and `IF` on the
461
+ measured bit compiles to a Qiskit `if_test`, so the conditional gate runs at
462
+ simulation time based on the actual outcome (no LOCC mode needed).
463
+
464
+ ```
465
+ 10 H 0
466
+ 20 MEAS 0 -> c Mid-circuit measurement into classical bit c
467
+ 30 IF c THEN X 0 Feedforward correction (also: IF c == 0, NOT c, with ELSE)
468
+ 40 MEASURE
469
+ ```
470
+
471
+ ## Mixed states
472
+
473
+ ```
474
+ SET_DENSITY [[0.5,0],[0,0.5]] Inject a density matrix (uses density_matrix method)
475
+ ```
476
+
477
+ ## Device model
478
+
479
+ Constrain transpilation to a hardware topology and native gate set, fully
480
+ offline. After RUN, the routed depth and SWAP count are reported.
481
+
482
+ ```
483
+ COUPLING linear 1D chain connectivity (also: ring, full, OFF, or 0-1, 1-2, ...)
484
+ BASIS rz, sx, x, cx Restrict to a native gate set (BASIS OFF to clear)
485
+ ```
486
+
487
+ ## Import and images
488
+
489
+ ```
490
+ LOADQASM file.qasm Import OpenQASM as an editable program (2.0 built-in; 3.0 needs qiskit_qasm3_import)
491
+ SAVEPNG out.png hist Save the histogram as a PNG (also: bloch, circuit; needs matplotlib)
492
+ ```
493
+
420
494
  ## Noise models
421
495
 
422
496
  ```
@@ -384,6 +384,80 @@ STATS SHOW Show mean/stddev/min/max per state
384
384
  STATS CLEAR Reset accumulator
385
385
  ```
386
386
 
387
+ ### State comparison
388
+ ```
389
+ FIDELITY |BELL> State fidelity |<target|psi>|^2 vs a named state
390
+ FIDELITY [0.707,0,0,0.707] ...or an explicit amplitude list
391
+ TOMOGRAPHY Reconstruct the density matrix from Pauli expectations
392
+ TOMOGRAPHY 2000 Statistical tomography (2000 shots per Pauli basis)
393
+ ```
394
+
395
+ ## Algorithm primitives
396
+
397
+ Composable building blocks applied to a qubit range (`lo-hi`, a list, or all
398
+ qubits). Qiskit-path only.
399
+
400
+ ```
401
+ QFT 0-3 Quantum Fourier transform over qubits 0..3
402
+ IQFT 0-3 Inverse QFT
403
+ DIFFUSE 0-2 Grover diffusion operator (2|s><s| - I)
404
+ MCX 0,1,2, 3 Multi-controlled X (any number of controls, last = target)
405
+ MCZ 0,1,2 Multi-controlled Z
406
+ MCP theta, 0,1, 2 Multi-controlled phase
407
+ QADD 0-2, 3-5 In-place register add: A += B (mod 2^n), qubit 0 = LSB
408
+ QADDC 5, 0-2 In-place constant add: A += 5 (mod 2^n)
409
+ QPE 0-3 4 UGATE Phase estimation of a UNITARY on a target register
410
+ ```
411
+
412
+ ## Optimization
413
+
414
+ Classical drivers over circuit parameters (VQE/QAOA). Build a parametrized
415
+ ansatz, compute a cost with `SAVE_EXPECT`, then minimize it.
416
+
417
+ ```
418
+ 10 RY theta, 0
419
+ 20 SAVE_EXPECT Z 0 -> cost
420
+ MINIMIZE theta -> cost Nelder-Mead minimization (dependency-free)
421
+ MINIMIZE a, b -> z0 + 0.5*z1 ITERS 200 Multi-parameter; cost is any post-run expression
422
+ GRADIENT theta -> cost Parameter-shift gradient d(cost)/d(theta)
423
+ ```
424
+
425
+ ## Dynamic circuits (feedforward)
426
+
427
+ In standard mode, `MEAS` is a real mid-circuit measurement and `IF` on the
428
+ measured bit compiles to a Qiskit `if_test`, so the conditional gate runs at
429
+ simulation time based on the actual outcome (no LOCC mode needed).
430
+
431
+ ```
432
+ 10 H 0
433
+ 20 MEAS 0 -> c Mid-circuit measurement into classical bit c
434
+ 30 IF c THEN X 0 Feedforward correction (also: IF c == 0, NOT c, with ELSE)
435
+ 40 MEASURE
436
+ ```
437
+
438
+ ## Mixed states
439
+
440
+ ```
441
+ SET_DENSITY [[0.5,0],[0,0.5]] Inject a density matrix (uses density_matrix method)
442
+ ```
443
+
444
+ ## Device model
445
+
446
+ Constrain transpilation to a hardware topology and native gate set, fully
447
+ offline. After RUN, the routed depth and SWAP count are reported.
448
+
449
+ ```
450
+ COUPLING linear 1D chain connectivity (also: ring, full, OFF, or 0-1, 1-2, ...)
451
+ BASIS rz, sx, x, cx Restrict to a native gate set (BASIS OFF to clear)
452
+ ```
453
+
454
+ ## Import and images
455
+
456
+ ```
457
+ LOADQASM file.qasm Import OpenQASM as an editable program (2.0 built-in; 3.0 needs qiskit_qasm3_import)
458
+ SAVEPNG out.png hist Save the histogram as a PNG (also: bloch, circuit; needs matplotlib)
459
+ ```
460
+
387
461
  ## Noise models
388
462
 
389
463
  ```
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "qubasic"
7
- version = "0.6.4"
7
+ version = "0.7.0"
8
8
  description = "Quantum BASIC Interactive Terminal"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.10"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qubasic
3
- Version: 0.6.4
3
+ Version: 0.7.0
4
4
  Summary: Quantum BASIC Interactive Terminal
5
5
  Author-email: "Charles C. Norton" <machineelv@gmail.com>
6
6
  License-Expression: MIT
@@ -417,6 +417,80 @@ STATS SHOW Show mean/stddev/min/max per state
417
417
  STATS CLEAR Reset accumulator
418
418
  ```
419
419
 
420
+ ### State comparison
421
+ ```
422
+ FIDELITY |BELL> State fidelity |<target|psi>|^2 vs a named state
423
+ FIDELITY [0.707,0,0,0.707] ...or an explicit amplitude list
424
+ TOMOGRAPHY Reconstruct the density matrix from Pauli expectations
425
+ TOMOGRAPHY 2000 Statistical tomography (2000 shots per Pauli basis)
426
+ ```
427
+
428
+ ## Algorithm primitives
429
+
430
+ Composable building blocks applied to a qubit range (`lo-hi`, a list, or all
431
+ qubits). Qiskit-path only.
432
+
433
+ ```
434
+ QFT 0-3 Quantum Fourier transform over qubits 0..3
435
+ IQFT 0-3 Inverse QFT
436
+ DIFFUSE 0-2 Grover diffusion operator (2|s><s| - I)
437
+ MCX 0,1,2, 3 Multi-controlled X (any number of controls, last = target)
438
+ MCZ 0,1,2 Multi-controlled Z
439
+ MCP theta, 0,1, 2 Multi-controlled phase
440
+ QADD 0-2, 3-5 In-place register add: A += B (mod 2^n), qubit 0 = LSB
441
+ QADDC 5, 0-2 In-place constant add: A += 5 (mod 2^n)
442
+ QPE 0-3 4 UGATE Phase estimation of a UNITARY on a target register
443
+ ```
444
+
445
+ ## Optimization
446
+
447
+ Classical drivers over circuit parameters (VQE/QAOA). Build a parametrized
448
+ ansatz, compute a cost with `SAVE_EXPECT`, then minimize it.
449
+
450
+ ```
451
+ 10 RY theta, 0
452
+ 20 SAVE_EXPECT Z 0 -> cost
453
+ MINIMIZE theta -> cost Nelder-Mead minimization (dependency-free)
454
+ MINIMIZE a, b -> z0 + 0.5*z1 ITERS 200 Multi-parameter; cost is any post-run expression
455
+ GRADIENT theta -> cost Parameter-shift gradient d(cost)/d(theta)
456
+ ```
457
+
458
+ ## Dynamic circuits (feedforward)
459
+
460
+ In standard mode, `MEAS` is a real mid-circuit measurement and `IF` on the
461
+ measured bit compiles to a Qiskit `if_test`, so the conditional gate runs at
462
+ simulation time based on the actual outcome (no LOCC mode needed).
463
+
464
+ ```
465
+ 10 H 0
466
+ 20 MEAS 0 -> c Mid-circuit measurement into classical bit c
467
+ 30 IF c THEN X 0 Feedforward correction (also: IF c == 0, NOT c, with ELSE)
468
+ 40 MEASURE
469
+ ```
470
+
471
+ ## Mixed states
472
+
473
+ ```
474
+ SET_DENSITY [[0.5,0],[0,0.5]] Inject a density matrix (uses density_matrix method)
475
+ ```
476
+
477
+ ## Device model
478
+
479
+ Constrain transpilation to a hardware topology and native gate set, fully
480
+ offline. After RUN, the routed depth and SWAP count are reported.
481
+
482
+ ```
483
+ COUPLING linear 1D chain connectivity (also: ring, full, OFF, or 0-1, 1-2, ...)
484
+ BASIS rz, sx, x, cx Restrict to a native gate set (BASIS OFF to clear)
485
+ ```
486
+
487
+ ## Import and images
488
+
489
+ ```
490
+ LOADQASM file.qasm Import OpenQASM as an editable program (2.0 built-in; 3.0 needs qiskit_qasm3_import)
491
+ SAVEPNG out.png hist Save the histogram as a PNG (also: bloch, circuit; needs matplotlib)
492
+ ```
493
+
420
494
  ## Noise models
421
495
 
422
496
  ```
@@ -15,6 +15,7 @@ qubasic.egg-info/requires.txt
15
15
  qubasic.egg-info/top_level.txt
16
16
  qubasic_core/__init__.py
17
17
  qubasic_core/__main__.py
18
+ qubasic_core/algorithms.py
18
19
  qubasic_core/analysis.py
19
20
  qubasic_core/backend.py
20
21
  qubasic_core/classic.py
@@ -28,7 +28,7 @@ __all__ = [
28
28
  'GATE_TABLE', 'GATE_ALIASES',
29
29
  ]
30
30
 
31
- __version__ = '0.6.4'
31
+ __version__ = '0.7.0'
32
32
 
33
33
  def __getattr__(name):
34
34
  """Lazy import heavy modules on first access."""