Skip to content

Commit 5332c97

Browse files
Merge pull request #54 from quantumdynamics927-dotcom/copilot/fix-cicd-pipeline-failures
Fix CI Python matrix failures from stray syntax in `space_server.py`
2 parents 92bd2fe + 2ea4d56 commit 5332c97

1 file changed

Lines changed: 11 additions & 24 deletions

File tree

space_server.py

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import os
66

7+
import numpy as np
78
import uvicorn
89
from fastapi import FastAPI, HTTPException
910
from fastapi.middleware.cors import CORSMiddleware
@@ -65,59 +66,45 @@ async def health_check():
6566
async def run_vqe(request: VQERequest):
6667
try:
6768
# Use simplified VQE (fallback) - works without pyscf
68-
from qiskit import QuantumCircuit
69-
from qiskit_aer import AerSimulator
70-
import numpy as np
71-
69+
7270
# Simplified H₂ VQE using 2-qubit ansatz
7371
def simplified_vqe(bond_length, shots=1024):
7472
# Create a simple 2-qubit ansatz
7573
theta = np.random.random() * 2 * np.pi
76-
74+
7775
# Simulate VQE optimization
7876
circuit = QuantumCircuit(2, 2)
7977
circuit.ry(theta, 0)
8078
circuit.cx(0, 1)
8179
circuit.measure([0, 1], [0, 1])
82-
83-
backend = AerSimulator()
84-
job = backend.run(circuit, shots=shots)
85-
result = job.result()
86-
counts = result.get_counts()
87-
80+
8881
# Calculate approximate energy based on bond length
8982
# H₂ ground state energy approximation
90-
exact = -1.116 + 0.5 * (bond_length - 0.74)**2
83+
exact = -1.116 + 0.5 * (bond_length - 0.74) ** 2
9184
vqe_energy = exact + np.random.normal(0, 0.01) # Small error
92-
85+
9386
return {
9487
"energy": vqe_energy,
9588
"error": abs(vqe_energy - exact),
9689
"depth": circuit.depth(),
97-
"iterations": np.random.randint(20, 50)
90+
"iterations": np.random.randint(20, 50),
9891
}
99-
100-
exact_energy = -1.116 + 0.5 * (request.bond_length - 0.74)**2
92+
93+
exact_energy = -1.116 + 0.5 * (request.bond_length - 0.74) ** 2
10194
result = simplified_vqe(request.bond_length, request.shots)
102-
95+
10396
return {
10497
"exact_energy": exact_energy,
10598
"vqe_energy": result["energy"],
10699
"error": result["error"],
107100
"depth": result["depth"],
108101
"iterations": result["iterations"],
109-
"mode": "simplified"
102+
"mode": "simplified",
110103
}
111104
except Exception as e:
112105
raise HTTPException(status_code=500, detail=str(e)) from e
113106

114107

115-
# Noisy Simulation Endpoint
116-
}
117-
except Exception as e:
118-
raise HTTPException(status_code=500, detail=str(e)) from e
119-
120-
121108
# Noisy Simulation Endpoint
122109
@app.post("/api/noisy")
123110
async def run_noisy_sim(request: NoisySimRequest):

0 commit comments

Comments
 (0)