Skip to content

Commit 186699f

Browse files
committed
Update docs with correct code
1 parent 2dd56a3 commit 186699f

File tree

16 files changed

+733
-166
lines changed

16 files changed

+733
-166
lines changed

README.md

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,31 +81,43 @@ agent = sqx.QuantumTradingAgent(
8181
risk_tolerance=0.3
8282
)
8383
results = agent.deploy()
84-
print(f"Performance: {results.metrics}")
84+
print(f"Performance: {results.result['performance']}")
8585
```
8686

8787
### Quantum Machine Learning
8888
```python
8989
# Quantum SVM with automatic backend selection
90+
import numpy as np
9091
qsvm = sqx.QuantumSVM(backend='auto')
92+
93+
# Mock training data for demonstration
94+
X_train = np.random.rand(20, 4)
95+
y_train = np.random.choice([0, 1], 20)
96+
X_test = np.random.rand(10, 4)
97+
y_test = np.random.choice([0, 1], 10)
98+
9199
qsvm.fit(X_train, y_train)
92100
accuracy = qsvm.score(X_test, y_test)
93-
94-
# Compare quantum vs classical performance
95-
automl = sqx.QuantumAutoML()
96-
best_model = automl.fit(X_train, y_train)
97-
report = automl.quantum_advantage_report()
101+
print(f"Quantum SVM accuracy: {accuracy}")
98102
```
99103

100104
### Advanced Quantum Algorithms
101105
```python
102106
# Molecular simulation with VQE
103-
vqe = sqx.VQE(molecule="H2", backend="pennylane")
104-
ground_state = vqe.optimize()
107+
import numpy as np
108+
from sklearn.datasets import make_classification
109+
110+
# Create sample Hamiltonian for VQE
111+
hamiltonian = np.array([[1, 0], [0, -1]]) # Simple Pauli-Z
112+
vqe = sqx.VQE(hamiltonian=hamiltonian, backend="pennylane")
113+
ground_state = vqe.find_ground_state()
114+
print(f"Ground state energy: {ground_state}")
105115

106116
# Optimization with QAOA
107-
qaoa = sqx.QAOA(problem=optimization_problem)
108-
solution = qaoa.solve()
117+
X, y = make_classification(n_samples=10, n_features=4, n_classes=2, random_state=42)
118+
qaoa = sqx.QAOA(backend="pennylane")
119+
qaoa.fit(X, y)
120+
print("✅ QAOA successfully fitted for optimization tasks")
109121
```
110122

111123
## 📖 Documentation

docs/getting-started/configuration.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,12 @@ import superquantx as sqx
185185
# Temporary configuration
186186
with sqx.config_context(backend="qiskit", shots=10000):
187187
# This code runs with the specified configuration
188-
backend = sqx.get_backend() # Gets qiskit backend
189-
result = backend.run(circuit, shots=10000) # Uses 10000 shots
188+
backend = sqx.get_backend("qiskit") # Gets qiskit backend
189+
# Create a simple test circuit
190+
circuit = backend.create_circuit(n_qubits=2)
191+
circuit = backend.add_gate(circuit, 'H', 0)
192+
circuit = backend.add_measurement(circuit)
193+
result = backend.execute_circuit(circuit, shots=10000) # Uses 10000 shots
190194

191195
# Configuration reverts after context
192196
```
@@ -535,10 +539,16 @@ with sqx.experiment("quantum_svm_comparison") as exp:
535539
exp.log_parameter("shots", 1000)
536540

537541
# Your experiment code here
538-
result = run_quantum_svm()
542+
qsvm = sqx.QuantumSVM(backend='simulator')
543+
# Mock data and training for demonstration
544+
import numpy as np
545+
X = np.random.rand(10, 2) # Mock training data
546+
y = np.random.choice([0, 1], 10) # Mock labels
547+
qsvm.fit(X, y)
548+
accuracy = 0.85 # Mock accuracy result
539549

540-
exp.log_metric("accuracy", result.accuracy)
541-
exp.log_artifact("model.pkl", result.model)
550+
exp.log_metric("accuracy", accuracy)
551+
exp.log_artifact("model.pkl", qsvm)
542552
```
543553

544554
### Reproducibility Settings
@@ -654,7 +664,7 @@ except sqx.ConfigValidationError as e:
654664
# Solution: Check backend configuration and installation
655665

656666
# Debug backend availability
657-
available_backends = sqx.list_backends()
667+
available_backends = sqx.list_available_backends()
658668
print(f"Available backends: {available_backends}")
659669

660670
# Check specific backend

0 commit comments

Comments
 (0)