From 4e5e5cead19503466bd0be55dc9bd3fa199e6a6a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 Feb 2023 05:21:35 +0000 Subject: [PATCH 1/2] [pre-commit.ci] pre-commit autoupdate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit updates: - [github.com/psf/black: 22.12.0 → 23.1.0](https://github.com/psf/black/compare/22.12.0...23.1.0) --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 07e39b00d9..29269e1270 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,7 +9,7 @@ repos: - id: check-yaml - id: debug-statements - repo: https://github.com/psf/black - rev: 22.12.0 + rev: 23.1.0 hooks: - id: black - repo: https://github.com/pycqa/isort From 50de63d06efb4b56bbbf106eb84ca3e56ee75d36 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 7 Feb 2023 05:21:49 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- doc/source/conf.py | 1 + examples/anomaly_detection/test.py | 1 - examples/qsvd/main.py | 1 - examples/qsvd/qsvd.py | 1 - examples/reuploading_classifier/datasets.py | 4 ++-- examples/variational_classifier/main.py | 1 - examples/vqregressor/main.py | 1 - src/qibo/models/grover.py | 1 - src/qibo/models/variational.py | 1 - src/qibo/tests/test_derivative.py | 1 - src/qibo/tests/test_noise.py | 2 -- 11 files changed, 3 insertions(+), 12 deletions(-) diff --git a/doc/source/conf.py b/doc/source/conf.py index 2ddfbb41e3..86cb150b8e 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -104,6 +104,7 @@ # autodoc_member_order = "bysource" + # Adapted this from # https://github.com/readthedocs/recommonmark/blob/ddd56e7717e9745f11300059e4268e204138a6b1/docs/conf.py # app setup hook diff --git a/examples/anomaly_detection/test.py b/examples/anomaly_detection/test.py index 6bf03a27b0..315b1611db 100644 --- a/examples/anomaly_detection/test.py +++ b/examples/anomaly_detection/test.py @@ -114,7 +114,6 @@ def compute_loss_test(encoder, vector): # Make graphs for performance analysis if plot: - """Loss distribution graph""" plt.hist(loss_a, bins=60, histtype="step", color="red", label="Anomalous data") plt.hist(loss_s, bins=60, histtype="step", color="blue", label="Standard data") diff --git a/examples/qsvd/main.py b/examples/qsvd/main.py index eec3d59c64..88b48f0f81 100644 --- a/examples/qsvd/main.py +++ b/examples/qsvd/main.py @@ -35,7 +35,6 @@ def main(nqubits, subsize, nlayers, nshots, RY, method, maxiter): - # We initialize the QSVD Qsvd = QSVD(nqubits, subsize, nlayers, RY=RY) diff --git a/examples/qsvd/qsvd.py b/examples/qsvd/qsvd.py index adf1c192fd..de41442322 100644 --- a/examples/qsvd/qsvd.py +++ b/examples/qsvd/qsvd.py @@ -158,7 +158,6 @@ def Schmidt_coeff(self, theta, init_state, nshots=100000): Schmidt = [] for i in range(2**small): - bit_string = bin(i)[2:].zfill(small) Schmidt.append(result[2 * bit_string]) diff --git a/examples/reuploading_classifier/datasets.py b/examples/reuploading_classifier/datasets.py index 4096b1e495..af54470410 100644 --- a/examples/reuploading_classifier/datasets.py +++ b/examples/reuploading_classifier/datasets.py @@ -91,7 +91,7 @@ def fig_template(name): elif name == "3_circles": centers = np.array([[-1, 1], [1, 0], [-0.5, -0.5]]) radii = np.array([1, np.sqrt(6 / np.pi - 1), 1 / 2]) - for (c, r) in zip(centers, radii): + for c, r in zip(centers, radii): for ax in axs: circle = plt.Circle(c, r, color="black", fill=False, zorder=10) ax.add_artist(circle) @@ -109,7 +109,7 @@ def fig_template(name): elif name == "crown" or name == "tricrown": centers = [[0, 0], [0, 0]] radii = [np.sqrt(0.8), np.sqrt(0.8 - 2 / np.pi)] - for (c, r) in zip(centers, radii): + for c, r in zip(centers, radii): for ax in axs: circle = plt.Circle(c, r, color="black", fill=False, zorder=10) ax.add_artist(circle) diff --git a/examples/variational_classifier/main.py b/examples/variational_classifier/main.py index a34ee36f56..3f8d7c37ac 100644 --- a/examples/variational_classifier/main.py +++ b/examples/variational_classifier/main.py @@ -34,7 +34,6 @@ def main(nclasses, nqubits, nlayers, nshots, training, RxRzRx, method): - # We initialize the quantum classifier RY = not RxRzRx qc = QuantumClassifer(nclasses, nqubits, nlayers, RY=RY) diff --git a/examples/vqregressor/main.py b/examples/vqregressor/main.py index ab3defb177..aef17da530 100644 --- a/examples/vqregressor/main.py +++ b/examples/vqregressor/main.py @@ -29,7 +29,6 @@ def main(layers, learning_rate, epochs, batches, ndata, J_treshold): - # We initialize the quantum regressor vqr = VQRegressor(layers=layers, ndata=ndata) # and the initial parameters diff --git a/src/qibo/models/grover.py b/src/qibo/models/grover.py index 4b05dc727a..3f19ab611b 100644 --- a/src/qibo/models/grover.py +++ b/src/qibo/models/grover.py @@ -67,7 +67,6 @@ def __init__( check_args=(), iterative=False, ): - self.oracle = oracle self.initial_state_circuit = initial_state_circuit diff --git a/src/qibo/models/variational.py b/src/qibo/models/variational.py index 3af4183355..ad925c97a6 100644 --- a/src/qibo/models/variational.py +++ b/src/qibo/models/variational.py @@ -167,7 +167,6 @@ def __init__( bounds_tolerance=1e-7, time_tolerance=1e-7, ): - if nsteps <= 0: # pragma: no cover raise_error( ValueError, diff --git a/src/qibo/tests/test_derivative.py b/src/qibo/tests/test_derivative.py index 15b635817d..cbe110a469 100644 --- a/src/qibo/tests/test_derivative.py +++ b/src/qibo/tests/test_derivative.py @@ -27,7 +27,6 @@ def circuit(nqubits=1): [(1, [8.51104358e-02, 5.20075970e-01, 0]), (0.5, [0.02405061, 0.13560379, 0])], ) def test_derivative(backend, scale_factor, grads): - # initializing the circuit c = circuit(nqubits=1) diff --git a/src/qibo/tests/test_noise.py b/src/qibo/tests/test_noise.py index 48ce2ae550..3bd1a5cd79 100644 --- a/src/qibo/tests/test_noise.py +++ b/src/qibo/tests/test_noise.py @@ -331,7 +331,6 @@ def test_kraus_error(backend, density_matrix, nshots): @pytest.mark.parametrize("idle_qubits", [True, False]) def test_noisy_circuit(backend, nshots, idle_qubits): if nshots != 20000: - circuit = Circuit(3, density_matrix=True) circuit.add( [ @@ -420,7 +419,6 @@ def test_noisy_circuit(backend, nshots, idle_qubits): backend.assert_allclose(final_samples, target_samples) else: - circuit = Circuit(3, density_matrix=True) circuit.add(