Skip to content

Commit

Permalink
added test
Browse files Browse the repository at this point in the history
  • Loading branch information
rupeshknn committed Dec 19, 2023
1 parent 9c629b1 commit 8815346
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions test/dynamics/backend/test_backend_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def test_basic_predict(self):
self.assertDictEqual(counts, {"0": 100})

def test_multi_qubit_predict(self):
"""Multi_qubit predict test case."""
"""Multi qubit predict test case."""
iq_data = _get_iq_data(
state=Statevector(np.array([0.5, 1, 0, 0]) / np.sqrt(1.25)),
measurement_subsystems=[0, 1],
Expand All @@ -297,8 +297,25 @@ def test_multi_qubit_predict(self):
self.assertDictEqual(counts0, {"0": 74, "1": 26})
self.assertDictEqual(counts1, {"1": 100})

def test_multi_qubit_with_1d_subsystem(self):
"""Multi qubit with 1d (trivial) subsystems."""
iq_data = _get_iq_data(
state=Statevector(np.array([0.5, 1, 0, 0]) / np.sqrt(1.25), dims=(1, 1, 2, 2, 1, 1)),
measurement_subsystems=[0, 1],
iq_centers=[[(1, 0), (-1, 0)], [(1, 0), (-1, 0)]],
iq_width=0.1,
shots=100,
memory_slot_indices=[0, 1],
seed=83248,
)

counts0 = self.iq_to_counts(iq_data[:, 0, :])
counts1 = self.iq_to_counts(iq_data[:, 1, :])
self.assertDictEqual(counts0, {"0": 74, "1": 26})
self.assertDictEqual(counts1, {"1": 100})

def test_mixed_subsystem_predict(self):
"""Multi_qubit predict test case."""
"""Multi qubit predict test case."""
iq_data = _get_iq_data(
state=Statevector(
np.kron(np.array([0.5, 1]), np.array([0, 0, 1])) / np.sqrt(1.25), dims=(3, 2)
Expand Down

0 comments on commit 8815346

Please sign in to comment.