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.
Files changed (59) hide show
  1. {qubasic-0.5.0/qubasic.egg-info → qubasic-0.5.1}/PKG-INFO +1 -1
  2. {qubasic-0.5.0 → qubasic-0.5.1}/pyproject.toml +1 -1
  3. {qubasic-0.5.0 → qubasic-0.5.1/qubasic.egg-info}/PKG-INFO +1 -1
  4. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/__init__.py +1 -1
  5. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/qol.py +80 -48
  6. {qubasic-0.5.0 → qubasic-0.5.1}/CHANGELOG.md +0 -0
  7. {qubasic-0.5.0 → qubasic-0.5.1}/LICENSE +0 -0
  8. {qubasic-0.5.0 → qubasic-0.5.1}/MANIFEST.in +0 -0
  9. {qubasic-0.5.0 → qubasic-0.5.1}/README.md +0 -0
  10. {qubasic-0.5.0 → qubasic-0.5.1}/examples/bell.qb +0 -0
  11. {qubasic-0.5.0 → qubasic-0.5.1}/examples/grover3.qb +0 -0
  12. {qubasic-0.5.0 → qubasic-0.5.1}/examples/locc_teleport.qb +0 -0
  13. {qubasic-0.5.0 → qubasic-0.5.1}/examples/sweep_rx.qb +0 -0
  14. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic.egg-info/SOURCES.txt +0 -0
  15. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic.egg-info/dependency_links.txt +0 -0
  16. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic.egg-info/entry_points.txt +0 -0
  17. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic.egg-info/requires.txt +0 -0
  18. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic.egg-info/top_level.txt +0 -0
  19. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic.py +0 -0
  20. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/__main__.py +0 -0
  21. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/analysis.py +0 -0
  22. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/backend.py +0 -0
  23. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/classic.py +0 -0
  24. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/control_flow.py +0 -0
  25. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/debug.py +0 -0
  26. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/demos.py +0 -0
  27. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/display.py +0 -0
  28. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/engine.py +0 -0
  29. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/engine_state.py +0 -0
  30. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/errors.py +0 -0
  31. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/exec_context.py +0 -0
  32. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/executor.py +0 -0
  33. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/expression.py +0 -0
  34. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/file_io.py +0 -0
  35. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/gates.py +0 -0
  36. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/help_text.py +0 -0
  37. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/io_protocol.py +0 -0
  38. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/locc.py +0 -0
  39. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/locc_commands.py +0 -0
  40. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/locc_display.py +0 -0
  41. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/locc_engine.py +0 -0
  42. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/locc_execution.py +0 -0
  43. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/memory.py +0 -0
  44. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/mock_backend.py +0 -0
  45. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/noise_mixin.py +0 -0
  46. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/parser.py +0 -0
  47. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/patterns.py +0 -0
  48. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/profiler.py +0 -0
  49. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/program_mgmt.py +0 -0
  50. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/protocol.py +0 -0
  51. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/scope.py +0 -0
  52. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/screen.py +0 -0
  53. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/state_display.py +0 -0
  54. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/statements.py +0 -0
  55. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/strings.py +0 -0
  56. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/subs.py +0 -0
  57. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/sweep.py +0 -0
  58. {qubasic-0.5.0 → qubasic-0.5.1}/qubasic_core/terminal.py +0 -0
  59. {qubasic-0.5.0 → qubasic-0.5.1}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: qubasic
3
- Version: 0.5.0
3
+ Version: 0.5.1
4
4
  Summary: Quantum BASIC Interactive Terminal
5
5
  Author-email: "Charles C. Norton" <machineelv@gmail.com>
6
6
  License-Expression: MIT
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "qubasic"
7
- version = "0.5.0"
7
+ version = "0.5.1"
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.5.0
3
+ Version: 0.5.1
4
4
  Summary: Quantum BASIC Interactive Terminal
5
5
  Author-email: "Charles C. Norton" <machineelv@gmail.com>
6
6
  License-Expression: MIT
@@ -28,7 +28,7 @@ __all__ = [
28
28
  'GATE_TABLE', 'GATE_ALIASES',
29
29
  ]
30
30
 
31
- __version__ = '0.5.0'
31
+ __version__ = '0.5.1'
32
32
 
33
33
  def __getattr__(name):
34
34
  """Lazy import heavy modules on first access."""
@@ -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 (Hadamard)',
582
- 'X': 'flip qubit {q} (NOT gate)',
583
- 'Y': 'apply Pauli-Y to qubit {q}',
584
- 'Z': 'flip the phase of qubit {q}',
585
- 'S': 'apply pi/2 phase to qubit {q}',
586
- 'T': 'apply pi/4 phase to qubit {q}',
587
- 'CX': 'entangle qubits {q} (CNOT)',
588
- 'CZ': 'apply controlled-Z on qubits {q}',
589
- 'CCX': 'apply Toffoli (AND gate) on qubits {q}',
590
- 'SWAP': 'swap qubits {q}',
591
- 'RX': 'rotate qubit around X axis',
592
- 'RY': 'rotate qubit around Y axis',
593
- 'RZ': 'rotate qubit around Z axis',
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
- 'NEXT': 'end of loop',
598
- 'WHILE': 'loop while condition holds',
599
- 'WEND': 'end of WHILE loop',
600
- 'IF': 'conditional branch',
601
- 'GOTO': 'jump to line',
602
- 'GOSUB': 'call subroutine',
603
- 'RETURN': 'return from subroutine',
604
- 'END': 'stop execution',
605
- 'MEASURE': 'measure all qubits',
606
- 'BARRIER': 'optimization barrier',
607
- 'PRINT': 'output text or value',
608
- 'LET': 'set variable',
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
- stmt = self.program[num].strip()
613
- upper = stmt.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
- desc = "(comment)"
618
- elif word in gate_desc:
619
- args = stmt.split(None, 1)[1] if ' ' in stmt else ''
620
- desc = gate_desc[word].format(q=args)
621
- elif word in flow_desc:
622
- desc = flow_desc[word]
623
- elif ':' in stmt:
624
- desc = f"multiple operations ({stmt.count(':') + 1} parts)"
625
- elif word.startswith('@'):
626
- desc = f"gate on LOCC register {word[1:]}"
627
- elif word == 'SEND':
628
- desc = "measure and send classical bit"
629
- elif word == 'SHARE':
630
- desc = "create shared entanglement"
631
- else:
632
- desc = stmt
633
- self.io.writeln(f" {num:5d} {desc}")
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