Skip to content

Commit

Permalink
Fixes of tests for the latest Qiskit (#2026)
Browse files Browse the repository at this point in the history
* fix test_aer_statevector

* fix daily test

* remove test case test.terra.states.test_aer_statevector.TestAerStatevector.test_number_to_latex_terms because of deprecation

* add release note and remove temporal on push
  • Loading branch information
doichanj committed Jan 16, 2024
1 parent ee51969 commit 08b07ce
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 24 deletions.
9 changes: 9 additions & 0 deletions releasenotes/notes/fix_for_daily_tests-3fa9df70fb3e53ee.yaml
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 3 additions & 1 deletion test/terra/noise/test_device_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
24 changes: 1 addition & 23 deletions test/terra/states/test_aer_statevector.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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]))
Expand Down

0 comments on commit 08b07ce

Please sign in to comment.