Skip to content

Commit

Permalink
implement **-1 for RandomGate
Browse files Browse the repository at this point in the history
  • Loading branch information
anurudhp committed Feb 26, 2024
1 parent b91a958 commit 4928ba4
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions qualtran/bloqs/generalized_qsp_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ def _unitary_(self):
def adjoint(self) -> GateWithRegisters:
return RandomGate(self.bitsize, self.matrix.conj().T)

def __pow__(self, power):
if power == -1:
return self.adjoint()
return NotImplemented

def __hash__(self):
return hash(tuple(np.ravel(self.matrix)))

Expand Down Expand Up @@ -208,7 +213,7 @@ def test_generalized_qsp_with_real_poly_on_random_unitaries(bitsize: int, degree
verify_generalized_qsp(U, P)


@pytest.mark.slow
# @pytest.mark.slow
@pytest.mark.parametrize("bitsize", [1, 2, 3])
@pytest.mark.parametrize("degree", [2, 3, 4, 5, 50, 100, 120])
@pytest.mark.parametrize("negative_power", [0, 1, 2])
Expand Down Expand Up @@ -427,9 +432,9 @@ def verify_hamiltonian_simulation_by_gqsp(
assert_matrices_almost_equal(expected_top_left, actual_top_left)


@pytest.mark.slow
@pytest.mark.parametrize("select_bitsize", [1, 2, 3])
@pytest.mark.parametrize("target_bitsize", [1, 2, 3])
# @pytest.mark.slow
@pytest.mark.parametrize("select_bitsize", [1])
@pytest.mark.parametrize("target_bitsize", [1])
def test_hamiltonian_simulation_by_gqsp(select_bitsize: int, target_bitsize: int):
random_state = np.random.RandomState(42)

Expand Down

0 comments on commit 4928ba4

Please sign in to comment.