From 1b55b88497b6c1f82a9d072f5d4ae0442190413e Mon Sep 17 00:00:00 2001 From: Yaiza Date: Wed, 10 Jul 2024 13:12:09 +0200 Subject: [PATCH] Fix lint --- ai-transpiler-demo.ipynb | 4 ++-- documentation-examples.ipynb | 4 ++-- qiskit_transpiler_service/transpiler_service.py | 2 +- qiskit_transpiler_service/wrappers/base.py | 4 ++-- qiskit_transpiler_service/wrappers/transpile.py | 2 +- tests/test_transpiler_service.py | 12 ++++++------ 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/ai-transpiler-demo.ipynb b/ai-transpiler-demo.ipynb index d4c0c42..8f1cf23 100644 --- a/ai-transpiler-demo.ipynb +++ b/ai-transpiler-demo.ipynb @@ -212,7 +212,7 @@ "\n", "qiskit_lvl3_transpiler_service = TranspilerService(\n", " backend_name=\"ibm_torino\",\n", - " ai='false',\n", + " ai=\"false\",\n", " optimization_level=3,\n", ")" ] @@ -281,7 +281,7 @@ "source": [ "qiskit_lvl3_ai_transpiler_service = TranspilerService(\n", " backend_name=\"ibm_torino\",\n", - " ai='true',\n", + " ai=\"true\",\n", " optimization_level=3,\n", ")" ] diff --git a/documentation-examples.ipynb b/documentation-examples.ipynb index 494179d..6d9bfca 100644 --- a/documentation-examples.ipynb +++ b/documentation-examples.ipynb @@ -22,7 +22,7 @@ "\n", "cloud_transpiler_service = TranspilerService(\n", " backend_name=\"ibm_sherbrooke\",\n", - " ai='false',\n", + " ai=\"false\",\n", " optimization_level=3,\n", ")\n", "transpiled_circuit_no_ai = cloud_transpiler_service.run(circuit)" @@ -50,7 +50,7 @@ "\n", "cloud_transpiler_service = TranspilerService(\n", " backend_name=\"ibm_sherbrooke\",\n", - " ai='true',\n", + " ai=\"true\",\n", " optimization_level=1,\n", ")\n", "transpiled_circuit_ai = cloud_transpiler_service.run(circuit)" diff --git a/qiskit_transpiler_service/transpiler_service.py b/qiskit_transpiler_service/transpiler_service.py index 9741123..6b6ee6c 100644 --- a/qiskit_transpiler_service/transpiler_service.py +++ b/qiskit_transpiler_service/transpiler_service.py @@ -57,7 +57,7 @@ class TranspilerService: def __init__( self, optimization_level: int, - ai: Literal['true', 'false', 'auto'] = 'true', + ai: Literal["true", "false", "auto"] = "true", coupling_map: Union[List[List[int]], None] = None, backend_name: Union[str, None] = None, qiskit_transpile_options: Dict = None, diff --git a/qiskit_transpiler_service/wrappers/base.py b/qiskit_transpiler_service/wrappers/base.py index d2143e4..9b39e18 100644 --- a/qiskit_transpiler_service/wrappers/base.py +++ b/qiskit_transpiler_service/wrappers/base.py @@ -182,8 +182,8 @@ def _get_error_msg_from_response(exc: requests.exceptions.HTTPError): if isinstance(detail, str): msg = detail elif isinstance(detail, list): - detail_input = detail[0]['input'] - detail_msg = detail[0]['msg'] + detail_input = detail[0]["input"] + detail_msg = detail[0]["msg"] if detail_input and detail_msg: msg = f"Wrong input '{detail_input}'. {detail_msg}" diff --git a/qiskit_transpiler_service/wrappers/transpile.py b/qiskit_transpiler_service/wrappers/transpile.py index 053b126..96f02ef 100644 --- a/qiskit_transpiler_service/wrappers/transpile.py +++ b/qiskit_transpiler_service/wrappers/transpile.py @@ -43,7 +43,7 @@ def transpile( optimization_level: int = 1, backend: Union[str, None] = None, coupling_map: Union[List[List[int]], None] = None, - ai: Literal['true', 'false', 'auto'] = 'true', + ai: Literal["true", "false", "auto"] = "true", qiskit_transpile_options: Dict = None, ai_layout_mode: str = None, ): diff --git a/tests/test_transpiler_service.py b/tests/test_transpiler_service.py index 4661ab0..e6543ff 100644 --- a/tests/test_transpiler_service.py +++ b/tests/test_transpiler_service.py @@ -32,7 +32,7 @@ @pytest.mark.parametrize( "optimization_level", [1, 2, 3], ids=["opt_level_1", "opt_level_2", "opt_level_3"] ) -@pytest.mark.parametrize("ai", ['false', 'true'], ids=["no_ai", "ai"]) +@pytest.mark.parametrize("ai", ["false", "true"], ids=["no_ai", "ai"]) @pytest.mark.parametrize( "qiskit_transpile_options", [None, {"seed_transpiler": 0}], @@ -56,7 +56,7 @@ def test_rand_circ_backend_routing(optimization_level, ai, qiskit_transpile_opti @pytest.mark.parametrize( "optimization_level", [1, 2, 3], ids=["opt_level_1", "opt_level_2", "opt_level_3"] ) -@pytest.mark.parametrize("ai", ['false', 'true'], ids=["no_ai", "ai"]) +@pytest.mark.parametrize("ai", ["false", "true"], ids=["no_ai", "ai"]) @pytest.mark.parametrize( "qiskit_transpile_options", [None, {"seed_transpiler": 0}], @@ -85,7 +85,7 @@ def test_qv_backend_routing(optimization_level, ai, qiskit_transpile_options): ], ) @pytest.mark.parametrize("optimization_level", [1, 2, 3]) -@pytest.mark.parametrize("ai", ['false', 'true'], ids=["no_ai", "ai"]) +@pytest.mark.parametrize("ai", ["false", "true"], ids=["no_ai", "ai"]) @pytest.mark.parametrize("qiskit_transpile_options", [None, {"seed_transpiler": 0}]) def test_rand_circ_cmap_routing( coupling_map, optimization_level, ai, qiskit_transpile_options @@ -108,7 +108,7 @@ def test_qv_circ_several_circuits_routing(): cloud_transpiler_service = TranspilerService( backend_name="ibm_brisbane", - ai='true', + ai="true", optimization_level=1, ) transpiled_circuit = cloud_transpiler_service.run([qv_circ] * 2) @@ -129,7 +129,7 @@ def test_qv_circ_wrong_input_routing(): cloud_transpiler_service = TranspilerService( backend_name="ibm_brisbane", - ai='true', + ai="true", optimization_level=1, ) @@ -138,7 +138,7 @@ def test_qv_circ_wrong_input_routing(): cloud_transpiler_service.run(circ_dict) -@pytest.mark.parametrize("ai", ['false', 'true'], ids=["no_ai", "ai"]) +@pytest.mark.parametrize("ai", ["false", "true"], ids=["no_ai", "ai"]) def test_transpile_layout_reconstruction(ai): n_qubits = 27