From 561eeda2a1b294f8e5fb4bf8e7039b27fe110a4f Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Wed, 10 Jan 2024 14:10:29 +0900 Subject: [PATCH 1/4] fix test_aer_statevector --- .github/workflows/unit-tests-latest-qiskit.yml | 5 +++++ test/terra/states/test_aer_statevector.py | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/.github/workflows/unit-tests-latest-qiskit.yml b/.github/workflows/unit-tests-latest-qiskit.yml index 425538529c..e152192c0e 100644 --- a/.github/workflows/unit-tests-latest-qiskit.yml +++ b/.github/workflows/unit-tests-latest-qiskit.yml @@ -1,5 +1,10 @@ name: Unit Tests for latest Qiskit on: +on: + push: + branches: [main, 'stable/*'] + pull_request: + branches: [main, 'stable/*'] schedule: - cron: '0 5 * * *' concurrency: diff --git a/test/terra/states/test_aer_statevector.py b/test/terra/states/test_aer_statevector.py index 4de8c9af2e..60bb646e51 100644 --- a/test/terra/states/test_aer_statevector.py +++ b/test/terra/states/test_aer_statevector.py @@ -32,7 +32,7 @@ from qiskit.quantum_info.operators.operator import Operator from qiskit.quantum_info.operators.symplectic import Pauli, SparsePauliOp from qiskit.quantum_info.operators.predicates import matrix_equal -from qiskit.visualization.state_visualization import numbers_to_latex_terms, state_to_latex +from qiskit.visualization.state_visualization import _numbers_to_latex_terms, state_to_latex from qiskit.circuit.library import QFT, HGate from test.terra import common @@ -1392,7 +1392,7 @@ def test_number_to_latex_terms(self): ] with self.assertWarns(DeprecationWarning): for numbers, latex_terms in cases: - terms = numbers_to_latex_terms(numbers, 15) + terms = _numbers_to_latex_terms(numbers, 15) self.assertListEqual(terms, latex_terms) def test_statevector_draw_latex_regression(self): From bb912749f01d80e6c5d414c392992364539762b3 Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Wed, 10 Jan 2024 14:15:15 +0900 Subject: [PATCH 2/4] fix daily test --- .github/workflows/unit-tests-latest-qiskit.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/unit-tests-latest-qiskit.yml b/.github/workflows/unit-tests-latest-qiskit.yml index e152192c0e..f7c05f819f 100644 --- a/.github/workflows/unit-tests-latest-qiskit.yml +++ b/.github/workflows/unit-tests-latest-qiskit.yml @@ -1,5 +1,4 @@ name: Unit Tests for latest Qiskit -on: on: push: branches: [main, 'stable/*'] From 0e8134c9f1689638d9ffbd921d0ceb675e5aa14e Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Thu, 11 Jan 2024 11:37:37 +0900 Subject: [PATCH 3/4] remove test case test.terra.states.test_aer_statevector.TestAerStatevector.test_number_to_latex_terms because of deprecation --- test/terra/noise/test_device_models.py | 4 +++- test/terra/states/test_aer_statevector.py | 24 +---------------------- 2 files changed, 4 insertions(+), 24 deletions(-) diff --git a/test/terra/noise/test_device_models.py b/test/terra/noise/test_device_models.py index 0035f38bdb..aad6c1e38c 100644 --- a/test/terra/noise/test_device_models.py +++ b/test/terra/noise/test_device_models.py @@ -59,7 +59,9 @@ def test_basic_device_gate_errors_from_target_and_properties(self): errors_from_properties = basic_device_gate_errors(properties=FakeNairobi().properties()) errors_from_target = basic_device_gate_errors(target=FakeNairobiV2().target) self.assertEqual(len(errors_from_properties), len(errors_from_target)) - for err_properties, err_target in zip(errors_from_properties, errors_from_target): + errors_from_properties_s = sorted(errors_from_properties) + errors_from_target_s = sorted(errors_from_target) + for err_properties, err_target in zip(errors_from_properties_s, errors_from_target_s): name1, qargs1, err1 = err_properties name2, qargs2, err2 = err_target self.assertEqual(name1, name2) diff --git a/test/terra/states/test_aer_statevector.py b/test/terra/states/test_aer_statevector.py index 60bb646e51..43ef209b6b 100644 --- a/test/terra/states/test_aer_statevector.py +++ b/test/terra/states/test_aer_statevector.py @@ -32,7 +32,7 @@ from qiskit.quantum_info.operators.operator import Operator from qiskit.quantum_info.operators.symplectic import Pauli, SparsePauliOp from qiskit.quantum_info.operators.predicates import matrix_equal -from qiskit.visualization.state_visualization import _numbers_to_latex_terms, state_to_latex +from qiskit.visualization.state_visualization import state_to_latex from qiskit.circuit.library import QFT, HGate from test.terra import common @@ -1373,28 +1373,6 @@ def test_state_to_latex_for_large_sparse_statevector(self): latex_representation = state_to_latex(sv) self.assertEqual(latex_representation, " |000000000000000\\rangle") - def test_number_to_latex_terms(self): - """Test conversions of complex numbers to latex terms""" - - cases = [ - ([1 - 8e-17, 0], ["", None]), - ([0, -1], [None, "-"]), - ([0, 1], [None, ""]), - ([0, 1j], [None, "i"]), - ([-1, 1], ["-", "+"]), - ([0, 1j], [None, "i"]), - ([-1, 1j], ["-", "+i"]), - ([1e-16 + 1j], ["i"]), - ([-1 + 1e-16 * 1j], ["-"]), - ([-1, -1 - 1j], ["-", "+(-1 - i)"]), - ([np.sqrt(2) / 2, np.sqrt(2) / 2], ["\\frac{\\sqrt{2}}{2}", "+\\frac{\\sqrt{2}}{2}"]), - ([1 + np.sqrt(2)], ["(1 + \\sqrt{2})"]), - ] - with self.assertWarns(DeprecationWarning): - for numbers, latex_terms in cases: - terms = _numbers_to_latex_terms(numbers, 15) - self.assertListEqual(terms, latex_terms) - def test_statevector_draw_latex_regression(self): """Test numerical rounding errors are not printed""" sv = AerStatevector(np.array([1 - 8e-17, 8.32667268e-17j])) From 896d0e4c771ad4efe1d8300f0ec56d455e6e70a8 Mon Sep 17 00:00:00 2001 From: Jun Doi Date: Tue, 16 Jan 2024 14:36:41 +0900 Subject: [PATCH 4/4] add release note and remove temporal on push --- .github/workflows/unit-tests-latest-qiskit.yml | 4 ---- .../notes/fix_for_daily_tests-3fa9df70fb3e53ee.yaml | 9 +++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/fix_for_daily_tests-3fa9df70fb3e53ee.yaml diff --git a/.github/workflows/unit-tests-latest-qiskit.yml b/.github/workflows/unit-tests-latest-qiskit.yml index f7c05f819f..425538529c 100644 --- a/.github/workflows/unit-tests-latest-qiskit.yml +++ b/.github/workflows/unit-tests-latest-qiskit.yml @@ -1,9 +1,5 @@ name: Unit Tests for latest Qiskit on: - push: - branches: [main, 'stable/*'] - pull_request: - branches: [main, 'stable/*'] schedule: - cron: '0 5 * * *' concurrency: diff --git a/releasenotes/notes/fix_for_daily_tests-3fa9df70fb3e53ee.yaml b/releasenotes/notes/fix_for_daily_tests-3fa9df70fb3e53ee.yaml new file mode 100644 index 0000000000..784cda289f --- /dev/null +++ b/releasenotes/notes/fix_for_daily_tests-3fa9df70fb3e53ee.yaml @@ -0,0 +1,9 @@ +--- +fixes: + - | + Removed deprecate function test in + test.terra.states.test_aer_statevector.TestAerStatevector.test_number_to_latex_terms + + Sorted the output properties in + test.terra.noise.test_device_models.test_basic_device_gate_errors_from_target_and_properties + to compare correctly.