Skip to content
This repository has been archived by the owner on Jun 12, 2023. It is now read-only.

Commit

Permalink
Bump pylint version to the latest release (#577)
Browse files Browse the repository at this point in the history
This commit bumps the pylint version we use for CI and local style
enforcement to be the latest release 2.8.2 and updates the code so that
the new pylint version passes. One place to note is a new rule looking
for potentially unbalanced tuple rule is disabled because the number of
values in the return tuple from the rb circuit generator varies
depending on the input (so we can't fix the code to pass the rule.
The version we were using was missing python 3.9 support and causes issues
for anyone running locally with python 3.9. This fixes this so we can
run pylint with all supported versions of python.
  • Loading branch information
mtreinish authored May 4, 2021
1 parent 2f47127 commit aee4868
Show file tree
Hide file tree
Showing 10 changed files with 18 additions and 13 deletions.
4 changes: 2 additions & 2 deletions constraints.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
pylint==2.4.4
astroid==2.3.3
pylint==2.8.2
astroid==2.5.6
pywin32==225
setuptools==49.6.0
pyfakefs==4.1.0
Expand Down
4 changes: 2 additions & 2 deletions qiskit/ignis/measurement/discriminator/discriminators.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,10 +286,10 @@ def _scale_data(self, xdata: List[List[float]],

try:
from sklearn.preprocessing import StandardScaler
except ImportError:
except ImportError as exc:
raise ImportError("To scale the xdata scikit-learn must be "
"installed. This can be done with 'pip install "
"scikit-learn'")
"scikit-learn'") from exc

if not self._scaler or refit:
self._scaler = StandardScaler(with_std=True)
Expand Down
4 changes: 2 additions & 2 deletions qiskit/ignis/measurement/discriminator/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ def get_base(expected_states: dict):
for char in expected_states[key]:
try:
value = int(char)
except ValueError:
except ValueError as exc:
raise QiskitError('Cannot parse character in ' +
expected_states[key])
expected_states[key]) from exc

base = base if base > value else value

Expand Down
4 changes: 2 additions & 2 deletions qiskit/ignis/measurement/discriminator/iq_discriminators.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,9 +275,9 @@ def plot(self, axs=None,
zz = np.array(zz).astype(float).reshape(xx.shape)
axs[0].contourf(xx, yy, zz, alpha=.2)

except ValueError:
except ValueError as exc:
raise QiskitError('Cannot convert expected state labels to '
'float.')
'float.') from exc

n_qubits = len(self._qubit_mask)
if show_fitting_data:
Expand Down
4 changes: 2 additions & 2 deletions qiskit/ignis/mitigation/expval/complete_mitigator.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,8 @@ def assignment_matrix(self, qubits: List[int] = None) -> np.ndarray:
qubits = [qubits]

# Compute marginal matrix
axis = tuple([self._num_qubits - 1 - i for i in set(
range(self._num_qubits)).difference(qubits)])
axis = tuple(self._num_qubits - 1 - i for i in set(
range(self._num_qubits)).difference(qubits))
num_qubits = len(qubits)
new_amat = np.zeros(2 * [2 ** num_qubits], dtype=float)
for i, col in enumerate(self._assignment_mat.T[self._keep_indexes(qubits)]):
Expand Down
3 changes: 1 addition & 2 deletions qiskit/ignis/verification/accreditation/fitters.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,4 @@ def bound_variation_distance(self, theta):
self.bound = self.bound/(self.N_acc/self.num_runs-theta)
self.bound = self.bound+1-self.g_num
self.confidence = 1-2*np.exp(-2*theta*self.num_runs*self.num_runs)
if self.bound > 1:
self.bound = 1
self.bound = min(self.bound, 1)
2 changes: 2 additions & 0 deletions qiskit/ignis/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=consider-using-with

"""Functions for getting version information about ignis."""


Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
pylint==2.4.4
pylint==2.8.2
pycodestyle
qiskit-aer>=0.3.0
scikit-learn>=0.17
Expand Down
3 changes: 3 additions & 0 deletions test/rb/generate_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# Any modifications or derivative works of this code must retain this
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.

# pylint: disable=unbalanced-tuple-unpacking

"""
Generate data for rb fitters tests
"""
Expand Down
1 change: 1 addition & 0 deletions test/rb/test_rb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# that they have been altered from the originals.

# pylint: disable=undefined-loop-variable,invalid-name,missing-type-doc
# pylint: disable=unbalanced-tuple-unpacking

"""
Run through RB for different qubit numbers to check that it's working
Expand Down

0 comments on commit aee4868

Please sign in to comment.