Skip to content

Commit 8fb35fc

Browse files
committed
Fix spelling and CI checks
1 parent c524c47 commit 8fb35fc

File tree

7 files changed

+32
-30
lines changed

7 files changed

+32
-30
lines changed

.pylintdict

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ cobyla
7777
codebase
7878
codec
7979
coeffs
80+
coles
8081
colin
8182
combinatorial
83+
computable
8284
concha
8385
config
8486
configs
@@ -335,6 +337,7 @@ msg
335337
multiclass
336338
multinomial
337339
multioutput
340+
multipartite
338341
mxd
339342
mypy
340343
nabla
@@ -511,7 +514,7 @@ scipy
511514
sdg
512515
seealso
513516
semidefinite
514-
sep
517+
sep
515518
seperate
516519
seperable
517520
serializable

qiskit_machine_learning/datasets/entanglement_concentration.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def entanglement_concentration_data(
5050
amounts of Concentration Of Entanglement (CE) and their corresponding class labels.
5151
These states are generated by the effect of two different pre-trained ansatz
5252
on fully seperable input states according to the procedure outlined in [1]. Pre-trained
53-
data in courtesy of L Schatzki et el [3]. The datapoints can be fully separated using
53+
data in courtesy of L Schatzki et al [3]. The datapoints can be fully separated using
5454
the SWAP test outlined in [2]. First, input states are randomly generated from a
5555
uniform distribution, using a sampling method determined by the ``sampling_method``
5656
argument. Next, based on the ``mode`` argument, two pre-trained circuits "A" and "B"
@@ -152,21 +152,21 @@ def entanglement_concentration_data(
152152
raise ValueError("Invalid sampling method. Must be 'isotropic' or 'cardinal'")
153153
if sampling_method == "cardinal" and n_points >= (6**n):
154154
raise ValueError(
155-
"""Cardinal Sampling cannot generate a large number of unique
156-
datapoints due to the limited number of combinations possible.
155+
"""Cardinal Sampling cannot generate a large number of unique
156+
datapoints due to the limited number of combinations possible.
157157
Try "isotropic" sampling method"""
158158
)
159159
if formatting not in {"statevector", "ndarray"}:
160160
raise ValueError(
161-
"""Formatting must be "statevector" or "ndarray". Please check for
161+
"""Formatting must be "statevector" or "ndarray". Please check for
162162
case sensitivity."""
163163
)
164164

165165
# Warnings
166166
if sampling_method == "cardinal" and n_points > (3**n):
167167
warnings.warn(
168-
"""Cardinal Sampling for large number of samples is not recommended
169-
and can lead to an arbitrarily large generation time due to
168+
"""Cardinal Sampling for large number of samples is not recommended
169+
and can lead to an arbitrarily large generation time due to
170170
repeating datapoints. Try "isotropic" sampling method""",
171171
UserWarning,
172172
)
@@ -244,7 +244,7 @@ def _assign_parameters(
244244
expected = 3 * depth * n_qubits
245245
if len(weights) != expected:
246246
raise ValueError(
247-
"""Parameter mismatch – please reinstall the latest 'qiskit-machine-learning'
247+
"""Parameter mismatch – please reinstall the latest 'qiskit-machine-learning'
248248
package (or update the model files).""",
249249
)
250250

qiskit_machine_learning/gradients/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This code is part of a Qiskit project.
22
#
3-
# (C) Copyright IBM 2022, 2024.
3+
# (C) Copyright IBM 2022, 2025.
44
#
55
# This code is licensed under the Apache License, Version 2.0. You may
66
# obtain a copy of this license in the LICENSE.txt file in the root directory

qiskit_machine_learning/gradients/base/base_qgt.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,9 @@ def __init__(
9393
precision: Precision to be used by the underlying Estimator. If provided, this number
9494
takes precedence over the default precision of the primitive. If None, the default
9595
precision of the primitive is used.
96-
transpiler: An optional object with a `run` method allowing to transpile the circuits
96+
pass_manager: An optional object with a `run` method allowing to transpile the circuits
9797
that are run when using this algorithm. If set to `None`, these won't be
9898
transpiled.
99-
transpiler_options: A dictionary of options to be passed to the transpiler's `run`
100-
method as keyword arguments.
10199
"""
102100
self._estimator: BaseEstimatorV2 = estimator
103101
self._precision = precision
@@ -107,7 +105,9 @@ def __init__(
107105
self._gradient_circuit_cache: dict[tuple, GradientCircuit] = {}
108106

109107
self._pass_manager = pass_manager
110-
self._pass_manager_options = pass_manager_options if pass_manager_options is not None else {}
108+
self._pass_manager_options = (
109+
pass_manager_options if pass_manager_options is not None else {}
110+
)
111111

112112
@property
113113
def derivative_type(self) -> DerivativeType:

qiskit_machine_learning/gradients/lin_comb/lin_comb_qgt.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
from __future__ import annotations
1717

1818
from collections.abc import Sequence
19-
from typing import Any
2019

2120
import numpy as np
2221

@@ -269,7 +268,7 @@ def _run_unique(
269268
# Compute the QGT
270269
qgts = []
271270
partial_sum_n = 0
272-
for phase_fix, n, m in zip(phase_fixes, all_n, all_m):
271+
for phase_fix, n, m in zip(phase_fixes, all_n, all_m): # type: ignore
273272
qgt = np.zeros((m, m), dtype="complex")
274273
# Compute the first term in the QGT
275274
if self.derivative_type == DerivativeType.COMPLEX:
@@ -311,7 +310,7 @@ def _run_unique(
311310
else:
312311
for i, (precision_, result) in enumerate(zip(precision, results)):
313312
if precision_ is None:
314-
precision[i] = results[i].metadata["target_precision"]
313+
precision[i] = results[i].metadata["target_precision"] # type: ignore
315314

316315
return QGTResult(
317316
qgts=qgts, derivative_type=self.derivative_type, metadata=metadata, precision=precision

qiskit_machine_learning/gradients/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This code is part of a Qiskit project.
22
#
3-
# (C) Copyright IBM 2022, 2024.
3+
# (C) Copyright IBM 2022, 2025.
44
#
55
# This code is licensed under the Apache License, Version 2.0. You may
66
# obtain a copy of this license in the LICENSE.txt file in the root directory

test/gradients/test_qgt.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from qiskit.circuit.library import real_amplitudes
2525
from qiskit.primitives import StatevectorEstimator
2626

27-
from qiskit_algorithms.gradients import DerivativeType, LinCombQGT, ReverseQGT
27+
from qiskit_machine_learning.gradients import DerivativeType, LinCombQGT
2828

2929
from .logging_primitives import LoggingEstimator
3030

@@ -37,10 +37,10 @@ def setUp(self):
3737
super().setUp()
3838
self.estimator = StatevectorEstimator()
3939

40-
@data(LinCombQGT, ReverseQGT)
40+
@data(LinCombQGT)
4141
def test_qgt_derivative_type(self, qgt_type):
4242
"""Test QGT derivative_type"""
43-
args = () if qgt_type == ReverseQGT else (self.estimator,)
43+
args = ()
4444
qgt = qgt_type(*args, derivative_type=DerivativeType.REAL)
4545

4646
a, b = Parameter("a"), Parameter("b")
@@ -76,10 +76,10 @@ def test_qgt_derivative_type(self, qgt_type):
7676
qgt_result = qgt.run([qc], [param]).result().qgts
7777
np.testing.assert_allclose(qgt_result[0], correct_values[i], atol=1e-3)
7878

79-
@data(LinCombQGT, ReverseQGT)
79+
@data(LinCombQGT)
8080
def test_qgt_phase_fix(self, qgt_type):
8181
"""Test the phase-fix argument in a QGT calculation"""
82-
args = () if qgt_type == ReverseQGT else (self.estimator,)
82+
args = ()
8383
qgt = qgt_type(*args, phase_fix=False)
8484

8585
# create the circuit
@@ -116,10 +116,10 @@ def test_qgt_phase_fix(self, qgt_type):
116116
qgt_result = qgt.run([qc], [param]).result().qgts
117117
np.testing.assert_allclose(qgt_result[0], correct_values[i], atol=1e-3)
118118

119-
@data(LinCombQGT, ReverseQGT)
119+
@data(LinCombQGT)
120120
def test_qgt_coefficients(self, qgt_type):
121121
"""Test the derivative option of QGT"""
122-
args = () if qgt_type == ReverseQGT else (self.estimator,)
122+
args = ()
123123
qgt = qgt_type(*args, derivative_type=DerivativeType.REAL)
124124

125125
qc = real_amplitudes(num_qubits=2, reps=1)
@@ -154,10 +154,10 @@ def test_qgt_coefficients(self, qgt_type):
154154
qgt_result = qgt.run([qc], [param]).result().qgts
155155
np.testing.assert_allclose(qgt_result[0], correct_values[i], atol=1e-3)
156156

157-
@data(LinCombQGT, ReverseQGT)
157+
@data(LinCombQGT)
158158
def test_qgt_parameters(self, qgt_type):
159159
"""Test the QGT with specified parameters"""
160-
args = () if qgt_type == ReverseQGT else (self.estimator,)
160+
args = ()
161161
qgt = qgt_type(*args, derivative_type=DerivativeType.REAL)
162162

163163
a = Parameter("a")
@@ -199,10 +199,10 @@ def test_qgt_parameters(self, qgt_type):
199199
qgt_result = qgt.run([qc2], [param_values], [param]).result().qgts
200200
np.testing.assert_allclose(qgt_result[0], expected[i], atol=1e-3)
201201

202-
@data(LinCombQGT, ReverseQGT)
202+
@data(LinCombQGT)
203203
def test_qgt_multi_arguments(self, qgt_type):
204204
"""Test the QGT for multiple arguments"""
205-
args = () if qgt_type == ReverseQGT else (self.estimator,)
205+
args = ()
206206
qgt = qgt_type(*args, derivative_type=DerivativeType.REAL)
207207

208208
a = Parameter("a")
@@ -221,10 +221,10 @@ def test_qgt_multi_arguments(self, qgt_type):
221221
for i, _ in enumerate(param_list):
222222
np.testing.assert_allclose(qgt_results[i], correct_values[i], atol=1e-3)
223223

224-
@data(LinCombQGT, ReverseQGT)
224+
@data(LinCombQGT)
225225
def test_qgt_validation(self, qgt_type):
226226
"""Test estimator QGT's validation"""
227-
args = () if qgt_type == ReverseQGT else (self.estimator,)
227+
args = ()
228228
qgt = qgt_type(*args)
229229

230230
a = Parameter("a")

0 commit comments

Comments
 (0)