From f17eb1d611aff90020751d669af4362cfe41f3e8 Mon Sep 17 00:00:00 2001 From: wrightjandrew <115216427+wrightjandrew@users.noreply.github.com> Date: Sat, 16 Mar 2024 09:03:10 +0100 Subject: [PATCH] Revert "Test coverage for fail cases in polynomial step" This reverts commit 00f6d8c89b03fccb3494779dbb25b0f1aa360a82. --- tests/test_models_dbi.py | 6 ++--- tests/test_models_dbi_utils.py | 1 - tests/test_models_dbi_utils_scheduling.py | 30 ----------------------- 3 files changed, 3 insertions(+), 34 deletions(-) delete mode 100644 tests/test_models_dbi_utils_scheduling.py diff --git a/tests/test_models_dbi.py b/tests/test_models_dbi.py index 5fa277f7ac..1dcbb960d0 100644 --- a/tests/test_models_dbi.py +++ b/tests/test_models_dbi.py @@ -137,6 +137,7 @@ def test_double_bracket_iteration_scheduling_grid_hyperopt( @pytest.mark.parametrize("n", [2, 4]) def test_double_bracket_iteration_scheduling_polynomial(backend, nqubits, n): h0 = random_hermitian(2**nqubits, backend=backend, seed=seed) + d = backend.cast(np.diag(np.diag(backend.to_numpy(h0)))) dbi = DoubleBracketIteration( Hamiltonian(nqubits, h0, backend=backend), mode=DoubleBracketGeneratorType.single_commutator, @@ -144,7 +145,6 @@ def test_double_bracket_iteration_scheduling_polynomial(backend, nqubits, n): ) initial_off_diagonal_norm = dbi.off_diagonal_norm for _ in range(NSTEPS): - # by default, d is the diagonal resctriction of H - step1 = dbi.choose_step(n=n) - dbi(step=step1) + step1 = dbi.choose_step(d=d, n=n) + dbi(d=d, step=step1) assert initial_off_diagonal_norm > dbi.off_diagonal_norm diff --git a/tests/test_models_dbi_utils.py b/tests/test_models_dbi_utils.py index a19ee502c5..cd9f74e9de 100644 --- a/tests/test_models_dbi_utils.py +++ b/tests/test_models_dbi_utils.py @@ -37,7 +37,6 @@ def test_select_best_dbr_generator(backend, nqubits, step): dbi = DoubleBracketIteration( Hamiltonian(nqubits, h0, backend=backend), mode=DoubleBracketGeneratorType.single_commutator, - scheduling=DoubleBracketScheduling.grid_search, ) generate_Z = generate_Z_operators(nqubits) Z_ops = list(generate_Z.values()) diff --git a/tests/test_models_dbi_utils_scheduling.py b/tests/test_models_dbi_utils_scheduling.py deleted file mode 100644 index 392727f144..0000000000 --- a/tests/test_models_dbi_utils_scheduling.py +++ /dev/null @@ -1,30 +0,0 @@ -"""Unit testing for utils_scheduling.py for Double Bracket Iteration""" - -import numpy as np -import pytest - -from qibo.hamiltonians import Hamiltonian -from qibo.models.dbi.double_bracket import ( - DoubleBracketGeneratorType, - DoubleBracketIteration, - DoubleBracketScheduling, -) -from qibo.models.dbi.utils_scheduling import polynomial_step -from qibo.quantum_info import random_hermitian - -NSTEPS = 1 -seed = 10 -"""Number of steps for evolution.""" - - -@pytest.mark.parametrize("nqubits", [5, 6]) -def test_polynomial_fail_cases(backend, nqubits): - h0 = random_hermitian(2**nqubits, backend=backend, seed=seed) - dbi = DoubleBracketIteration( - Hamiltonian(nqubits, h0, backend=backend), - mode=DoubleBracketGeneratorType.single_commutator, - scheduling=DoubleBracketScheduling.polynomial_approximation, - ) - with pytest.raises(ValueError): - polynomial_step(dbi, n=2, n_max=1) - assert polynomial_step(dbi, n=1) == None