Skip to content

Commit 217d47b

Browse files
Merge pull request #52 from quantumdynamics927-dotcom/copilot/fix-ci-cd-pipeline-errors
Fix CI test matrix failures caused by Ruff errors in `app.py`
2 parents 18b872c + 4d6083b commit 217d47b

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

app.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
"""
55

66
import gradio as gr
7-
import numpy as np
7+
88
from quantumpytho.engine import QuantumEngine
99
from quantumpytho.modules.bloch_ascii import one_qubit_from_angles
1010
from quantumpytho.modules.circuit_explorer import bell_pair
1111

1212
# Initialize quantum engine
1313
engine = QuantumEngine()
1414

15+
1516
def bloch_sphere_demo(theta, phi):
1617
"""Generate Bloch sphere ASCII visualization."""
1718
try:
@@ -20,40 +21,48 @@ def bloch_sphere_demo(theta, phi):
2021
except Exception as e:
2122
return f"Error: {str(e)}"
2223

24+
2325
def create_bell_pair():
2426
"""Create a Bell pair and return circuit diagram."""
2527
try:
2628
circuit = bell_pair()
27-
return circuit.draw(output='text')
29+
return circuit.draw(output="text")
2830
except Exception as e:
2931
return f"Error: {str(e)}"
3032

33+
3134
def run_quantum_teleport():
3235
"""Run quantum teleportation demo."""
3336
try:
3437
from quantumpytho.modules.teleport_bridge import build_teleport_circuit
38+
3539
circuit = build_teleport_circuit()
3640
result = engine.run(circuit)
3741
return f"Teleportation circuit executed successfully!\n\nCounts: {result}"
3842
except Exception as e:
3943
return f"Error: {str(e)}"
4044

45+
4146
def run_qec_demo(code_type="Shor"):
4247
"""Run Quantum Error Correction demo."""
4348
try:
4449
if code_type == "Shor":
4550
from quantumpytho.modules.qec_shor import run_shor_qec_demo
51+
4652
return run_shor_qec_demo()
4753
else:
4854
from quantumpytho.modules.qec_steane import run_steane_qec_demo
55+
4956
return run_steane_qec_demo()
5057
except Exception as e:
5158
return f"Error: {str(e)}"
5259

60+
5361
def generate_qrng(count, phi_scale=False):
5462
"""Generate quantum random numbers."""
5563
try:
5664
from quantumpytho.modules.qrng_sacred import qrng_phi_sequence
65+
5766
if phi_scale:
5867
result = qrng_phi_sequence(count)
5968
return f"QRNG with phi-scaling:\n{result}"
@@ -67,6 +76,7 @@ def generate_qrng(count, phi_scale=False):
6776
except Exception as e:
6877
return f"Error: {str(e)}"
6978

79+
7080
# Create Gradio interface
7181
def create_interface():
7282
with gr.Blocks(title="QPyth - Quantum Computing") as demo:
@@ -75,54 +85,59 @@ def create_interface():
7585
7686
A professionally engineered quantum computing library built on Qiskit.
7787
""")
78-
88+
7989
with gr.Tab("Bloch Sphere"):
8090
gr.Markdown("Visualize quantum states on the Bloch sphere")
8191
with gr.Row():
8292
theta = gr.Slider(0, 180, value=45, label="Theta (degrees)")
8393
phi = gr.Slider(0, 360, value=45, label="Phi (degrees)")
8494
bloch_output = gr.Textbox(label="Bloch Sphere Visualization", lines=20)
8595
bloch_btn = gr.Button("Generate")
86-
bloch_btn.click(bloch_sphere_demo, inputs=[theta, phi], outputs=bloch_output)
87-
96+
bloch_btn.click(
97+
bloch_sphere_demo, inputs=[theta, phi], outputs=bloch_output
98+
)
99+
88100
with gr.Tab("Bell Pair"):
89101
gr.Markdown("Create an entangled Bell pair")
90102
bell_output = gr.Textbox(label="Circuit", lines=15)
91103
bell_btn = gr.Button("Create Bell Pair")
92104
bell_btn.click(create_bell_pair, outputs=bell_output)
93-
105+
94106
with gr.Tab("Quantum Teleportation"):
95107
gr.Markdown("Run the quantum teleportation protocol")
96108
teleport_output = gr.Textbox(label="Result", lines=10)
97109
teleport_btn = gr.Button("Run Teleportation")
98110
teleport_btn.click(run_quantum_teleport, outputs=teleport_output)
99-
111+
100112
with gr.Tab("Quantum Error Correction"):
101113
gr.Markdown("Demonstrate quantum error correction codes")
102114
code_type = gr.Radio(["Shor", "Steane"], label="Code Type", value="Shor")
103115
qec_output = gr.Textbox(label="Result", lines=15)
104116
qec_btn = gr.Button("Run QEC Demo")
105117
qec_btn.click(run_qec_demo, inputs=code_type, outputs=qec_output)
106-
118+
107119
with gr.Tab("Quantum RNG"):
108120
gr.Markdown("Generate quantum random numbers")
109121
with gr.Row():
110122
count = gr.Slider(1, 100, value=10, step=1, label="Number of values")
111123
phi_scale = gr.Checkbox(label="Use phi-scaling")
112124
qrng_output = gr.Textbox(label="Random Numbers", lines=10)
113125
qrng_btn = gr.Button("Generate")
114-
qrng_btn.click(generate_qrng, inputs=[count, phi_scale], outputs=qrng_output)
115-
126+
qrng_btn.click(
127+
generate_qrng, inputs=[count, phi_scale], outputs=qrng_output
128+
)
129+
116130
gr.Markdown("""
117131
---
118132
119133
**Note**: This is a demo interface. For full functionality including VQE,
120134
IBM Quantum hardware access, and the complete web UI, please use the CLI or
121135
deploy the full application.
122136
""")
123-
137+
124138
return demo
125139

140+
126141
# Launch the app
127142
if __name__ == "__main__":
128143
demo = create_interface()

0 commit comments

Comments
 (0)