Skip to content

Commit

Permalink
Improve deprecation warning to clarify what gate was detected as cust…
Browse files Browse the repository at this point in the history
…om. Fix typo. (#13460) (#13462)

(cherry picked from commit 7f19daa)

Co-authored-by: Elena Peña Tapia <[email protected]>
  • Loading branch information
mergify[bot] and ElePT authored Nov 20, 2024
1 parent 3c20e1a commit 3b8f523
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -479,10 +479,11 @@ def _parse_basis_gates(basis_gates, backend, inst_map, skip_target):
if inst not in standard_gates and inst not in default_gates:
warnings.warn(
category=DeprecationWarning,
message="Providing custom gates through the ``basis_gates`` argument is deprecated "
"for both ``transpile`` and ``generate_preset_pass_manager`` as of Qiskit 1.3.0. "
message=f"Providing non-standard gates ({inst}) through the ``basis_gates`` "
"argument is deprecated for both ``transpile`` and ``generate_preset_pass_manager`` "
"as of Qiskit 1.3.0. "
"It will be removed in Qiskit 2.0. The ``target`` parameter should be used instead. "
"You can build a target instance using ``Target.from_configuration()`` and provide"
"You can build a target instance using ``Target.from_configuration()`` and provide "
"custom gate definitions with the ``custom_name_mapping`` argument.",
)
skip_target = True
Expand Down
6 changes: 3 additions & 3 deletions test/python/transpiler/test_preset_passmanagers.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ def test_unitary_is_preserved_if_in_basis(self, level):
qc.measure_all()
with self.assertWarnsRegex(
DeprecationWarning,
"Providing custom gates through the ``basis_gates`` argument is deprecated",
"Providing non-standard gates \\(unitary\\) through the ``basis_gates`` argument",
):
result = transpile(qc, basis_gates=["cx", "u", "unitary"], optimization_level=level)
self.assertEqual(result, qc)
Expand All @@ -185,7 +185,7 @@ def test_unitary_is_preserved_if_in_basis_synthesis_translation(self, level):
qc.measure_all()
with self.assertWarnsRegex(
DeprecationWarning,
"Providing custom gates through the ``basis_gates`` argument is deprecated",
"Providing non-standard gates \\(unitary\\) through the ``basis_gates`` argument",
):
result = transpile(
qc,
Expand Down Expand Up @@ -1761,7 +1761,7 @@ def test_custom_basis_gates_raise(self, optimization_level):
basis_gates = ["my_gate"]
with self.assertWarnsRegex(
DeprecationWarning,
"Providing custom gates through the ``basis_gates`` argument is deprecated",
"Providing non-standard gates \\(my_gate\\) through the ``basis_gates`` argument",
):
_ = generate_preset_pass_manager(
optimization_level=optimization_level, basis_gates=basis_gates
Expand Down

0 comments on commit 3b8f523

Please sign in to comment.