qubasic 0.5.0__tar.gz → 0.5.1__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.
- {qubasic-0.5.0/qubasic.egg-info → qubasic-0.5.1}/PKG-INFO +1 -1
- {qubasic-0.5.0 → qubasic-0.5.1}/pyproject.toml +1 -1
- {qubasic-0.5.0 → qubasic-0.5.1/qubasic.egg-info}/PKG-INFO +1 -1
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/__init__.py +1 -1
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/qol.py +80 -48
- {qubasic-0.5.0 → qubasic-0.5.1}/CHANGELOG.md +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/LICENSE +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/MANIFEST.in +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/README.md +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/examples/bell.qb +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/examples/grover3.qb +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/examples/locc_teleport.qb +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/examples/sweep_rx.qb +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic.egg-info/SOURCES.txt +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic.egg-info/dependency_links.txt +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic.egg-info/entry_points.txt +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic.egg-info/requires.txt +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic.egg-info/top_level.txt +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/__main__.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/analysis.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/backend.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/classic.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/control_flow.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/debug.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/demos.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/display.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/engine.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/engine_state.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/errors.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/exec_context.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/executor.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/expression.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/file_io.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/gates.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/help_text.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/io_protocol.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/locc.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/locc_commands.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/locc_display.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/locc_engine.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/locc_execution.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/memory.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/mock_backend.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/noise_mixin.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/parser.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/patterns.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/profiler.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/program_mgmt.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/protocol.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/scope.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/screen.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/state_display.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/statements.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/strings.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/subs.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/sweep.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/terminal.py +0 -0
- {qubasic-0.5.0 → qubasic-0.5.1}/setup.cfg +0 -0
|
@@ -578,59 +578,91 @@ class QoLMixin:
|
|
|
578
578
|
return
|
|
579
579
|
from qubasic_core.gates import GATE_TABLE, GATE_ALIASES
|
|
580
580
|
gate_desc = {
|
|
581
|
-
'H': 'put qubit {q} in superposition
|
|
582
|
-
'X': 'flip qubit {q} (NOT
|
|
583
|
-
'Y': '
|
|
584
|
-
'Z': 'flip
|
|
585
|
-
'S': '
|
|
586
|
-
'T': '
|
|
587
|
-
'
|
|
588
|
-
'
|
|
589
|
-
'
|
|
590
|
-
'
|
|
591
|
-
'
|
|
592
|
-
'
|
|
593
|
-
'
|
|
581
|
+
'H': 'put qubit {q} in superposition',
|
|
582
|
+
'X': 'flip qubit {q} (NOT)',
|
|
583
|
+
'Y': 'Pauli-Y on qubit {q}',
|
|
584
|
+
'Z': 'flip phase of qubit {q}',
|
|
585
|
+
'S': 'S-phase on qubit {q}',
|
|
586
|
+
'T': 'T-phase on qubit {q}',
|
|
587
|
+
'SDG': 'S-dagger on qubit {q}',
|
|
588
|
+
'TDG': 'T-dagger on qubit {q}',
|
|
589
|
+
'SX': 'sqrt(X) on qubit {q}',
|
|
590
|
+
'ID': 'identity on qubit {q}',
|
|
591
|
+
'CX': 'CNOT: flip {q1} if {q0}=|1>',
|
|
592
|
+
'CZ': 'CZ: phase flip if both |1>',
|
|
593
|
+
'CY': 'controlled-Y',
|
|
594
|
+
'CH': 'controlled-H',
|
|
595
|
+
'CCX': 'Toffoli: flip {q2} if {q0},{q1}=|1>',
|
|
596
|
+
'CSWAP': 'Fredkin: swap if control=|1>',
|
|
597
|
+
'SWAP': 'swap qubits {q0} and {q1}',
|
|
598
|
+
'RX': 'rotate {q} around X by {p}',
|
|
599
|
+
'RY': 'rotate {q} around Y by {p}',
|
|
600
|
+
'RZ': 'rotate {q} around Z by {p}',
|
|
601
|
+
'P': 'phase({p}) on qubit {q}',
|
|
602
|
+
'CP': 'controlled-phase({p})',
|
|
603
|
+
'CRX': 'controlled-RX({p})',
|
|
604
|
+
'CRY': 'controlled-RY({p})',
|
|
605
|
+
'CRZ': 'controlled-RZ({p})',
|
|
606
|
+
'RXX': 'XX interaction({p})',
|
|
607
|
+
'RYY': 'YY interaction({p})',
|
|
608
|
+
'RZZ': 'ZZ interaction({p})',
|
|
609
|
+
'U': 'general unitary U({p})',
|
|
610
|
+
'DCX': 'double-CNOT',
|
|
611
|
+
'ISWAP': 'iSWAP',
|
|
594
612
|
}
|
|
595
613
|
flow_desc = {
|
|
596
|
-
'FOR': 'begin loop',
|
|
597
|
-
'
|
|
598
|
-
'
|
|
599
|
-
'
|
|
600
|
-
'
|
|
601
|
-
'
|
|
602
|
-
'
|
|
603
|
-
'
|
|
604
|
-
'
|
|
605
|
-
'
|
|
606
|
-
'
|
|
607
|
-
'
|
|
608
|
-
'
|
|
609
|
-
'DIM': 'create array',
|
|
614
|
+
'FOR': 'begin loop', 'NEXT': 'end of loop',
|
|
615
|
+
'WHILE': 'loop while condition holds', 'WEND': 'end of WHILE loop',
|
|
616
|
+
'IF': 'conditional branch', 'GOTO': 'jump to line',
|
|
617
|
+
'GOSUB': 'call subroutine', 'RETURN': 'return from subroutine',
|
|
618
|
+
'END': 'stop execution', 'MEASURE': 'measure all qubits',
|
|
619
|
+
'BARRIER': 'optimization barrier', 'PRINT': 'output text or value',
|
|
620
|
+
'LET': 'set variable', 'DIM': 'create array',
|
|
621
|
+
'DO': 'begin DO loop', 'LOOP': 'end of DO loop',
|
|
622
|
+
'EXIT': 'exit loop early', 'SELECT': 'begin SELECT CASE',
|
|
623
|
+
'CASE': 'match case', 'CALL': 'call subroutine',
|
|
624
|
+
'SUB': 'define subroutine', 'FUNCTION': 'define function',
|
|
625
|
+
'DATA': 'inline data', 'READ': 'read from DATA',
|
|
626
|
+
'RESTORE': 'reset DATA pointer',
|
|
610
627
|
}
|
|
611
628
|
for num in sorted(self.program.keys()):
|
|
612
|
-
|
|
613
|
-
upper =
|
|
614
|
-
word = upper.split()[0] if stmt.split() else ''
|
|
615
|
-
word = GATE_ALIASES.get(word, word)
|
|
629
|
+
raw = self.program[num].strip()
|
|
630
|
+
upper = raw.upper()
|
|
616
631
|
if upper.startswith('REM') or upper.startswith("'"):
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
632
|
+
self.io.writeln(f" {num:5d} (comment)")
|
|
633
|
+
continue
|
|
634
|
+
# Split on colons and explain each part
|
|
635
|
+
parts = [s.strip() for s in raw.split(':') if s.strip()]
|
|
636
|
+
descs = []
|
|
637
|
+
for part in parts:
|
|
638
|
+
word = part.split()[0].upper() if part.split() else ''
|
|
639
|
+
canonical = GATE_ALIASES.get(word, word)
|
|
640
|
+
if canonical in gate_desc:
|
|
641
|
+
info = GATE_TABLE.get(canonical)
|
|
642
|
+
args = part.split(None, 1)[1].strip() if ' ' in part else ''
|
|
643
|
+
arg_list = [a.strip() for a in args.split(',')]
|
|
644
|
+
n_params = info[0] if info else 0
|
|
645
|
+
params = arg_list[:n_params]
|
|
646
|
+
qubits = arg_list[n_params:]
|
|
647
|
+
fmt = gate_desc[canonical]
|
|
648
|
+
fmt = fmt.replace('{q}', ', '.join(qubits) if qubits else '?')
|
|
649
|
+
fmt = fmt.replace('{p}', ', '.join(params) if params else '?')
|
|
650
|
+
for i, q in enumerate(qubits):
|
|
651
|
+
fmt = fmt.replace(f'{{q{i}}}', q)
|
|
652
|
+
descs.append(fmt)
|
|
653
|
+
elif word in flow_desc:
|
|
654
|
+
descs.append(flow_desc[word])
|
|
655
|
+
elif word.startswith('@'):
|
|
656
|
+
reg = word[1:]
|
|
657
|
+
inner = part.split(None, 1)[1].strip() if ' ' in part else ''
|
|
658
|
+
descs.append(f"@{reg}: {inner}")
|
|
659
|
+
elif word == 'SEND':
|
|
660
|
+
descs.append("measure and send classical bit")
|
|
661
|
+
elif word == 'SHARE':
|
|
662
|
+
descs.append("create shared entanglement")
|
|
663
|
+
else:
|
|
664
|
+
descs.append(part)
|
|
665
|
+
self.io.writeln(f" {num:5d} {'; '.join(descs)}")
|
|
634
666
|
|
|
635
667
|
# ── #24: CLIP ─────────────────────────────────────────────────────
|
|
636
668
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|