Skip to content

Commit

Permalink
test: Add example from issue #1357 in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stavros11 committed Jun 24, 2024
1 parent 98fba39 commit e252331
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion tests/test_hamiltonians_trotter.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
import pytest

from qibo import hamiltonians
from qibo import hamiltonians, symbols
from qibo.backends import NumpyBackend
from qibo.quantum_info import random_hermitian, random_statevector

Expand Down Expand Up @@ -143,6 +143,14 @@ def test_trotter_hamiltonian_three_qubit_term(backend):
backend.assert_allclose(final_state, target_state)


def test_symbolic_hamiltonian_circuit_different_dts(backend):
"""Issue: https://github.com/qiboteam/qibo/issues/1357."""
ham = hamiltonians.SymbolicHamiltonian(symbols.Z(0))
a = ham.circuit(0.1)
b = ham.circuit(0.1)
assert np.linalg.norm(ham.circuit(0.2).unitary() - (a + b).unitary()) == 0


def test_old_trotter_hamiltonian_errors():
"""Check errors when creating the deprecated ``TrotterHamiltonian`` object."""
with pytest.raises(NotImplementedError):
Expand Down

0 comments on commit e252331

Please sign in to comment.