Skip to content

Commit 666c7d8

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 22b762c commit 666c7d8

27 files changed

Lines changed: 40 additions & 55 deletions

examples/unitary_simulator.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
"""Example of using the UnitarySimulator."""
1717

18-
1918
import numpy as np
2019

2120
from projectq.backends import UnitarySimulator

projectq/backends/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
* an interface to the Azure Quantum service devices (and simulators)
2929
* an interface to the IonQ trapped ionq hardware (and simulator).
3030
"""
31+
3132
from ._aqt import AQTBackend
3233
from ._awsbraket import AWSBraketBackend
3334
from ._azure import AzureQuantumBackend

projectq/backends/_awsbraket/_awsbraket_boto3_client_test.py

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
""" Test for projectq.backends._awsbraket._awsbraket_boto3_client.py """
14+
"""Test for projectq.backends._awsbraket._awsbraket_boto3_client.py"""
1515

1616
import pytest
1717

@@ -110,21 +110,15 @@ def test_retrieve(mocker, var_status, var_result, retrieve_setup):
110110
_awsbraket_boto3_client.retrieve(credentials=creds, task_arn=arntask, num_retries=2)
111111
print(exinfo.value)
112112
if var_status == 'failed':
113-
assert (
114-
str(exinfo.value)
115-
== "Error while running the code: FAILED. \
113+
assert str(exinfo.value) == "Error while running the code: FAILED. \
116114
The failure reason was: This is a failure reason."
117-
)
118115

119116
if var_status == 'cancelling':
120117
assert str(exinfo.value) == "The job received a CANCEL operation: CANCELLING."
121118
if var_status == 'other':
122-
assert (
123-
str(exinfo.value)
124-
== "Timeout. The Arn of your submitted job \
119+
assert str(exinfo.value) == "Timeout. The Arn of your submitted job \
125120
is arn:aws:braket:us-east-1:id:taskuuid \
126121
and the status of the job is OTHER."
127-
)
128122

129123

130124
# ==============================================================================
@@ -155,7 +149,7 @@ def test_retrieve_devicetypes(mocker, retrieve_devicetypes_setup):
155149

156150
@has_boto3
157151
def test_send_too_many_qubits(mocker, send_too_many_setup):
158-
(creds, s3_folder, search_value, device_value, info_too_much) = send_too_many_setup
152+
creds, s3_folder, search_value, device_value, info_too_much = send_too_many_setup
159153

160154
mock_boto3_client = mocker.MagicMock(spec=['search_devices', 'get_device'])
161155
mock_boto3_client.search_devices.return_value = search_value
@@ -222,21 +216,15 @@ def test_send_real_device_online_verbose(mocker, var_status, var_result, real_de
222216
)
223217
print(exinfo.value)
224218
if var_status == 'failed':
225-
assert (
226-
str(exinfo.value)
227-
== "Error while running the code: FAILED. The failure \
219+
assert str(exinfo.value) == "Error while running the code: FAILED. The failure \
228220
reason was: This is a failure reason."
229-
)
230221

231222
if var_status == 'cancelling':
232223
assert str(exinfo.value) == "The job received a CANCEL operation: CANCELLING."
233224
if var_status == 'other':
234-
assert (
235-
str(exinfo.value)
236-
== "Timeout. The Arn of your submitted job \
225+
assert str(exinfo.value) == "Timeout. The Arn of your submitted job \
237226
is arn:aws:braket:us-east-1:id:taskuuid \
238227
and the status of the job is OTHER."
239-
)
240228

241229

242230
# ==============================================================================
@@ -282,7 +270,7 @@ def test_send_that_errors_are_caught(mocker, var_error, send_that_error_setup):
282270

283271

284272
@has_boto3
285-
@pytest.mark.parametrize("var_error", [('ResourceNotFoundException')])
273+
@pytest.mark.parametrize("var_error", ['ResourceNotFoundException'])
286274
def test_retrieve_error_arn_not_exist(mocker, var_error, arntask, creds):
287275
mock_boto3_client = mocker.MagicMock(spec=['get_quantum_task'])
288276
mock_boto3_client.get_quantum_task.side_effect = botocore.exceptions.ClientError(

projectq/backends/_awsbraket/_awsbraket_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
""" Test for projectq.backends._awsbraket._awsbraket.py"""
14+
"""Test for projectq.backends._awsbraket._awsbraket.py"""
1515

1616
import copy
1717
import math
@@ -477,7 +477,7 @@ def test_awsbraket_sent_error_2():
477477

478478
@has_boto3
479479
def test_awsbraket_retrieve(mocker, retrieve_setup):
480-
(arntask, creds, completed_value, device_value, results_dict) = retrieve_setup
480+
arntask, creds, completed_value, device_value, results_dict = retrieve_setup
481481

482482
mock_boto3_client = mocker.MagicMock(spec=['get_quantum_task', 'get_device', 'get_object'])
483483
mock_boto3_client.get_quantum_task.return_value = completed_value

projectq/backends/_circuits/_drawer.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
"""Contain a compiler engine which generates TikZ Latex code describing the circuit."""
1616

17-
1817
from projectq.cengines import BasicEngine, LastEngineException
1918
from projectq.meta import get_control_count
2019
from projectq.ops import Allocate, Deallocate, FlushGate, Measure

projectq/backends/_circuits/_drawer_matplotlib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def _format_gate_str(cmd):
3030
param_str = ''
3131
gate_name = str(cmd.gate)
3232
if '(' in gate_name:
33-
(gate_name, param_str) = re.search(r'(.+)\((.*)\)', gate_name).groups()
33+
gate_name, param_str = re.search(r'(.+)\((.*)\)', gate_name).groups()
3434
params = re.findall(r'([^,]+)', param_str)
3535
params_str_list = []
3636
for param in params:

projectq/backends/_circuits/_plot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def draw_gates( # pylint: disable=too-many-arguments
308308
for qubit_line in qubit_lines.values():
309309
for idx, data in enumerate(qubit_line):
310310
if data is not None:
311-
(gate_str, targets, controls) = data
311+
gate_str, targets, controls = data
312312
targets_order = [drawing_order[tgt] for tgt in targets]
313313
draw_gate(
314314
axes,

projectq/backends/_circuits/_plot_test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414
"""
15-
Tests for projectq.backends._circuits._plot.py.
15+
Tests for projectq.backends._circuits._plot.py.
1616
17-
To generate the baseline images,
18-
run the tests with '--mpl-generate-path=baseline'
17+
To generate the baseline images,
18+
run the tests with '--mpl-generate-path=baseline'
1919
20-
Then run the tests simply with '--mpl'
20+
Then run the tests simply with '--mpl'
2121
"""
22+
2223
from copy import deepcopy
2324

2425
import pytest

projectq/backends/_ibm/_ibm_http_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414

1515
"""Back-end to run quantum program on IBM QE cloud platform."""
1616

17-
1817
# helpers to run the jsonified gate sequence on ibm quantum experience server
1918
# api documentation does not exist and has to be deduced from the qiskit code
2019
# source at: https://github.com/Qiskit/qiskit-ibmq-provider

projectq/backends/_ibm/_ibm_test.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -370,12 +370,8 @@ def mock_send(*args, **kwargs):
370370
assert prob_dict['00'] == pytest.approx(0.512)
371371
assert prob_dict['11'] == pytest.approx(0.488)
372372
result = "\nu2(0,pi/2) q[1];\ncx q[1], q[2];\ncx q[1], q[3];"
373-
if sys.version_info.major == 3:
374-
result += "\nu3(6.28318530718, 0, 0) q[1];\nu1(11.780972450962) q[1];"
375-
result += "\nu3(6.28318530718, 0, 0) q[1];\nu1(10.995574287564) q[1];"
376-
else:
377-
result += "\nu3(6.28318530718, 0, 0) q[1];\nu1(11.780972451) q[1];"
378-
result += "\nu3(6.28318530718, 0, 0) q[1];\nu1(10.9955742876) q[1];"
373+
result += "\nu3(6.28318530718, 0, 0) q[1];\nu1(11.780972450962) q[1];"
374+
result += "\nu3(6.28318530718, 0, 0) q[1];\nu1(10.995574287564) q[1];"
379375
result += "\nbarrier q[1], q[2], q[3];"
380376
result += "\nu3(0.2, -pi/2, pi/2) q[1];\nmeasure q[1] -> c[1];"
381377
result += "\nmeasure q[2] -> c[2];\nmeasure q[3] -> c[3];"

0 commit comments

Comments
 (0)