Skip to content

Commit

Permalink
Merge branch 'qutip:master' into qiskit-pulse-simulators
Browse files Browse the repository at this point in the history
  • Loading branch information
claretgrace0801 authored Sep 3, 2022
2 parents dc1f00a + a8d3c45 commit 6429ca1
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/test_circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ def test_N_level_system(self):
"""
Test for circuit with N-level system.
"""
mat3 = qp.rand_unitary_haar(3)
mat3 = qp.rand_unitary(3)

def controlled_mat3(arg_value):
"""
Expand Down
16 changes: 13 additions & 3 deletions tests/test_gates.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from copy import deepcopy
from packaging.version import parse as parse_version
import pytest
import functools
import itertools
Expand All @@ -23,7 +24,10 @@ def _infidelity(a, b):

def _make_random_three_qubit_gate():
"""Create a random three-qubit gate."""
operation = qutip.rand_unitary(8, dims=[[2]*3]*2)
if parse_version(qutip.__version__) < parse_version('5.dev'):
operation = qutip.rand_unitary(8, dims=[[2] * 3] * 2)
else:
operation = qutip.rand_unitary([2] * 3)

def gate(N=None, controls=None, target=None):
if N is None:
Expand Down Expand Up @@ -272,7 +276,10 @@ def test_permutation_without_expansion(self, permutation):
def test_general_qubit_expansion(self, n_targets):
# Test all permutations with the given number of targets.
n_qubits = 5
operation = qutip.rand_unitary(2**n_targets, dims=[[2]*n_targets]*2)
if parse_version(qutip.__version__) < parse_version('5.dev'):
operation = qutip.rand_unitary(2**n_targets, dims=[[2]*n_targets]*2)
else:
operation = qutip.rand_unitary([2]*n_targets)
for targets in itertools.permutations(range(n_qubits), n_targets):
expected = _tensor_with_entanglement([qutip.qeye(2)] * n_qubits,
operation, targets)
Expand Down Expand Up @@ -339,7 +346,10 @@ def test_non_qubit_systems(self, dimensions):
np.testing.assert_allclose(test.full(), expected.full())

def test_gates_class():
init_state = qutip.rand_ket(8, dims=[[2, 2, 2], [1, 1, 1]])
if parse_version(qutip.__version__) < parse_version('5.dev'):
init_state = qutip.rand_ket(8, dims=[[2, 2, 2], [1, 1, 1]])
else:
init_state = qutip.rand_ket([2, 2, 2])

circuit1 = QubitCircuit(3)
circuit1.add_gate("X", 1)
Expand Down
7 changes: 6 additions & 1 deletion tests/test_optpulseprocessor.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,12 @@ def test_with_model(self):
processor.load_circuit(
qc, merge_gates=True, num_tslots=10, evo_time=2.0
)
init_state = qutip.rand_ket(8, dims=[[2, 2, 2], [1, 1, 1]])

if parse_version(qutip.__version__) < parse_version('5.dev'):
init_state = qutip.rand_ket(8, dims=[[2, 2, 2], [1, 1, 1]])
else:
init_state = qutip.rand_ket([2, 2, 2])

num_result = processor.run_state(init_state=init_state).states[-1]
ideal_result = qc.run(init_state)
assert (
Expand Down

0 comments on commit 6429ca1

Please sign in to comment.