-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '1.0.3' of github.com:BQSKit/bqskit into 1.0.3
- Loading branch information
Showing
1 changed file
with
11 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,22 @@ | ||
from __future__ import annotations | ||
|
||
import numpy as np | ||
from bqskit import Circuit | ||
from bqskit.ir.gates import CNOTGate, U3Gate | ||
from bqskitrs import Circuit as CircuitRS | ||
|
||
from bqskit import Circuit | ||
from bqskit.ir.gates import CNOTGate | ||
from bqskit.ir.gates import U3Gate | ||
|
||
|
||
def test_basic() -> None: | ||
circuit = Circuit(3) | ||
for _ in range(10): | ||
for i in range(2): | ||
circuit.append_gate(CNOTGate(), (i, i+1)) | ||
circuit.append_gate(CNOTGate(), (i, i + 1)) | ||
circuit.append_gate(U3Gate(), i) | ||
circuit.append_gate(U3Gate(), i+1) | ||
circuit.append_gate(U3Gate(), i + 1) | ||
crs = CircuitRS(circuit) | ||
d, dM = crs.get_unitary_and_grad([0]*(2*10*6)) | ||
od, odM = circuit.get_unitary_and_grad([0]*(2*10*6)) | ||
d, dM = crs.get_unitary_and_grad([0] * (2 * 10 * 6)) | ||
od, odM = circuit.get_unitary_and_grad([0] * (2 * 10 * 6)) | ||
assert np.allclose(d, od) | ||
assert np.allclose(dM, odM) |