Skip to content

Commit

Permalink
Remove unused vars in test_quantum_operator_helpers.py (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
avawang1 authored May 6, 2020
1 parent 43a693b commit 265c412
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions test/unit_tests/braket/circuits/test_quantum_operator_helpers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import functools
import itertools

import numpy as np
import pytest
Expand Down Expand Up @@ -28,16 +27,7 @@

invalid_matrix_type_error = np.array([[0, 1], ["a", 0]])

x_matrix = np.array([[0, 1], [1, 0]])
y_matrix = np.array([[0, -1j], [1j, 0]])
z_matrix = np.array([[1, 0], [0, -1]])
h_matrix = 1 / np.sqrt(2) * np.array([[1, 1], [1, -1]])

standard_observables = [x_matrix, y_matrix, z_matrix, h_matrix]

matrix_pairs = [
np.kron(x, y) for x, y in list(itertools.product(standard_observables, standard_observables))
]


def test_verify_quantum_operator_matrix_dimensions():
Expand Down Expand Up @@ -82,20 +72,17 @@ def test_is_unitary_exception():
is_unitary(invalid_matrix_type_error)


@pytest.mark.parametrize("pauli", standard_observables)
def test_get_pauli_eigenvalues_correct_eigenvalues_one_qubit(pauli):
def test_get_pauli_eigenvalues_correct_eigenvalues_one_qubit():
"""Test the get_pauli_eigenvalues function for one qubit"""
assert np.array_equal(get_pauli_eigenvalues(1), np.diag(z_matrix))


@pytest.mark.parametrize("pauli_product", matrix_pairs)
def test_get_pauli_eigenvalues_correct_eigenvalues_two_qubits(pauli_product):
def test_get_pauli_eigenvalues_correct_eigenvalues_two_qubits():
"""Test the get_pauli_eigenvalues function for two qubits"""
assert np.array_equal(get_pauli_eigenvalues(2), np.diag(np.kron(z_matrix, z_matrix)))


@pytest.mark.parametrize("pauli_product", matrix_pairs)
def test_get_pauli_eigenvalues_correct_eigenvalues_three_qubits(pauli_product):
def test_get_pauli_eigenvalues_correct_eigenvalues_three_qubits():
"""Test the get_pauli_eigenvalues function for three qubits"""
assert np.array_equal(
get_pauli_eigenvalues(3), np.diag(np.kron(z_matrix, np.kron(z_matrix, z_matrix))),
Expand Down

0 comments on commit 265c412

Please sign in to comment.