Remove useless pylint suppressions (#2365)

* Remove useless pylint suppressions

* some of them are necesary
This commit is contained in:
Lev Bishop 2019-05-10 16:52:08 -04:00 committed by Luciano
parent 315ba5465f
commit ef04325d17
69 changed files with 34 additions and 103 deletions

View File

@ -20,7 +20,7 @@ from qiskit.exceptions import QiskitError
from .gate import Gate
class CompositeGate(Gate): # pylint: disable=abstract-method
class CompositeGate(Gate):
"""Composite gate, a sequence of unitary gates."""
def __init__(self, name, params, inverse_name=None):

View File

@ -12,7 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=too-many-boolean-expressions
"""
A generic quantum instruction.

View File

@ -125,7 +125,6 @@ class AstInterpreter:
Return a list of tuples (Register,index).
"""
# pylint: disable=inconsistent-return-statements
reg = None
if node.name in self.dag.qregs:
reg = self.dag.qregs[node.name]

View File

@ -20,7 +20,7 @@ from qiskit.circuit import Gate
from qiskit.circuit import QuantumCircuit
class CXBase(Gate): # pylint: disable=abstract-method
class CXBase(Gate):
"""Fundamental controlled-NOT gate."""
def __init__(self):

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name
"""
Identity gate.
"""

View File

@ -12,7 +12,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name,arguments-differ
# pylint: disable=invalid-name
"""
S=diag(1,i) Clifford phase gate or its inverse.

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name
"""
SWAP gate.
"""

View File

@ -12,7 +12,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name,arguments-differ
# pylint: disable=invalid-name
"""
T=sqrt(S) phase gate or its inverse.

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name
"""
Element of SU(2).
"""
@ -23,7 +21,7 @@ from qiskit.circuit import Gate
from qiskit.circuit import QuantumCircuit
class UBase(Gate): # pylint: disable=abstract-method
class UBase(Gate):
"""Element of SU(2)."""
def __init__(self, theta, phi, lam):

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name
"""
Pauli X (bit-flip) gate.
"""

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name
"""
Pauli Y (bit-phase-flip) gate.
"""

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name
"""
Pauli Z (phase-flip) gate.
"""

View File

@ -12,7 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name,assignment-from-no-return
"""
Arbitrary unitary circuit instruction.
"""

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=redundant-returns-doc,missing-raises-doc
"""Base class for a backend provider."""
from abc import ABC, abstractmethod

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name
"""Contains functions used by the basic aer simulators.
"""

View File

@ -12,7 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name
# pylint: disable=arguments-differ
"""Contains a (slow) python simulator.

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name
# pylint: disable=arguments-differ
"""Contains a (slow) python statevector simulator.

View File

@ -53,7 +53,6 @@ class UchannelLOSchema(BaseSchema):
class PulseHamiltonianSchema(BaseSchema):
"""Schema for PulseHamiltonian."""
# pylint: disable=redefined-builtin
# Required properties.
h_str = List(String(), validate=Length(min=1), required=True)

View File

@ -105,7 +105,6 @@ class DeviceSpecification:
"""Return qubits in this device."""
return self._qubits
# pylint: disable=invalid-name
@property
def c(self) -> List[RegisterSlot]:
"""Return register slots in this device."""

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name
"""Node for an OPENQASM external function."""
import sympy

View File

@ -78,7 +78,6 @@ class PulseQobjExperimentSchema(QobjExperimentSchema):
class PulseQobjConfigSchema(QobjConfigSchema):
"""Schema for PulseQobjConfig of device backend."""
# pylint: disable=invalid-name
# Required properties.
meas_level = Integer(required=True, validate=Range(min=0, max=2))

View File

@ -12,7 +12,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name,anomalous-backslash-in-string
# pylint: disable=invalid-name
"""
A collection of useful quantum information functions for operators.

View File

@ -36,9 +36,9 @@ class Quaternion:
def __str__(self):
return np.array_str(self.data)
def __mul__(self, r): # pylint: disable=C0103
def __mul__(self, r):
if isinstance(r, Quaternion):
q = self # pylint: disable=C0103
q = self
out_data = np.zeros(4, dtype=float)
out_data[0] = r(0)*q(0) - r(1)*q(1) - r(2)*q(2) - r(3)*q(3)
out_data[1] = r(0)*q(1) + r(1)*q(0) - r(2)*q(3) + r(3)*q(2)
@ -78,7 +78,7 @@ class Quaternion:
Returns:
ndarray: Rotation matrix.
"""
w, x, y, z = self.normalize().data # pylint: disable=C0103
w, x, y, z = self.normalize().data
mat = np.array([
[1-2*y**2-2*z**2, 2*x*y-2*z*w, 2*x*z+2*y*w],
[2*x*y+2*z*w, 1-2*x**2-2*z**2, 2*y*z-2*x*w],

View File

@ -5,8 +5,7 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name,invalid-sequence-index
# pylint: disable=unsupported-assignment-operation
# pylint: disable=invalid-name
"""
Methods to create random unitaries, states, etc.

View File

@ -12,7 +12,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name,anomalous-backslash-in-string
# pylint: disable=invalid-name
"""
A collection of useful quantum information functions for states.

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name,anomalous-backslash-in-string
"""
A collection of useful quantum information functions for states.

View File

@ -5,8 +5,7 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name,invalid-sequence-index
# pylint: disable=unsupported-assignment-operation
# pylint: disable=invalid-name
"""
Expand 2-qubit Unitary operators into an equivalent

View File

@ -55,10 +55,8 @@ class FakeProvider(BaseProvider):
def get_backend(self, name=None, **kwargs):
backend = self._backends[0]
if name:
# pylint: disable=no-member
filtered_backends = [backend for backend in self._backends
if backend.name() == name]
# pylint: enable=no-member
if not filtered_backends:
raise QiskitBackendNotFoundError()

View File

@ -29,7 +29,7 @@ from qiskit.exceptions import QiskitError
from qiskit.visualization.gate_map import plot_gate_map
try:
# pylint: disable=import-error,no-name-in-module
# pylint: disable=import-error
from qiskit.providers.ibmq import IBMQ, IBMQBackend
except ImportError:
pass

View File

@ -171,7 +171,7 @@ class ProgressBarMagic(Magics):
default='html',
help="Type of progress bar, 'html' or 'text'."
)
def qiskit_progress_bar(self, line='', cell=None): # pylint: disable=W0613
def qiskit_progress_bar(self, line='', cell=None):
"""A Jupyter magic function to generate progressbar.
"""
args = magic_arguments.parse_argstring(self.qiskit_progress_bar, line)

View File

@ -98,7 +98,7 @@ def job_monitor(job, interval=None, monitor_async=False, quiet=False, output=sys
except ImportError:
raise ImportError('These functions need ipywidgets. '
'Run "pip install ipywidgets" before.')
from qiskit.tools.jupyter.jupyter_magics import _html_checker # pylint: disable=C0412
from qiskit.tools.jupyter.jupyter_magics import _html_checker
style = "font-size:16px;"
header = "<p style='{style}'>Job Status: %s </p>".format(

View File

@ -12,9 +12,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name,anomalous-backslash-in-string
# pylint: disable=assignment-from-no-return
# pylint: disable=invalid-name
"""
A collection of useful quantum information functions.
@ -419,7 +417,6 @@ def shannon_entropy(pvec, base=2):
Returns:
float: The Shannon entropy H(pvec).
"""
# pylint: disable=missing-docstring
if base == 2:
def logfn(x):
return - x * np.log2(x)
@ -447,6 +444,7 @@ def entropy(state):
Returns:
float: The von-Neumann entropy S(rho).
"""
# pylint: disable=assignment-from-no-return
rho = np.array(state)
if rho.ndim == 1:

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=no-member
"""
Directed graph object for representing coupling between physical qubits.

View File

@ -26,9 +26,9 @@ from qiskit.transpiler.exceptions import TranspilerError
from qiskit.dagcircuit import DAGCircuit
from qiskit.extensions.standard import SwapGate
from qiskit.transpiler import Layout
# pylint: disable=no-name-in-module, import-error
# pylint: disable=no-name-in-module
from .cython.stochastic_swap.utils import nlayout_from_layout
# pylint: disable=no-name-in-module, import-error
# pylint: disable=no-name-in-module
from .cython.stochastic_swap.swap_trial import swap_trial
logger = getLogger(__name__)

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=unused-variable
"""
Level 0 pass manager:
no optimization, just conforming to basis and coupling map

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=unused-variable
"""
Level 1 pass manager:
mapping in addition to light optimization via adjacent gate collapse

View File

@ -174,7 +174,6 @@ class DictParameters(ModelTypeValidator):
return value
def _validate_values(self, value):
# pylint: disable=too-many-return-statements
if value is None:
return None
if isinstance(value, self.valid_value_types):
@ -187,7 +186,6 @@ class DictParameters(ModelTypeValidator):
return self.fail('invalid', input=value)
def _serialize(self, value, attr, obj):
# pylint: disable=too-many-return-statements
if value is None:
return None
if isinstance(value, Mapping):
@ -196,7 +194,6 @@ class DictParameters(ModelTypeValidator):
return self.fail('invalid_mapping')
def _deserialize(self, value, attr, data):
# pylint: disable=too-many-return-statements
if value is None:
return None
if isinstance(value, Mapping):

View File

@ -11,7 +11,6 @@
# 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=invalid-name
"""Main Qiskit visualization methods."""

View File

@ -13,7 +13,6 @@
# that they have been altered from the originals.
# TODO: Remove after 0.7 and the deprecated methods are removed
# pylint: disable=unused-argument
"""

View File

@ -12,7 +12,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name,missing-docstring,import-error
# pylint: disable=invalid-name,import-error
"""
Visualization functions for measurement counts.

View File

@ -12,8 +12,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name,anomalous-backslash-in-string,missing-docstring
# pylint: disable=consider-using-enumerate
# pylint: disable=invalid-name
"""latex circuit visualization backends."""

View File

@ -12,7 +12,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name,anomalous-backslash-in-string,missing-docstring
# pylint: disable=invalid-name,missing-docstring
"""mpl circuit visualization backend."""

View File

@ -12,7 +12,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name,anomalous-backslash-in-string,missing-docstring
# pylint: disable=invalid-name,missing-docstring
class DefaultStyle:

View File

@ -12,7 +12,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name,anomalous-backslash-in-string,ungrouped-imports,import-error
# pylint: disable=invalid-name,ungrouped-imports,import-error
"""
Visualization functions for quantum states.

View File

@ -420,7 +420,7 @@ class InputWire(DrawElement):
super().__init__(label)
@staticmethod
def fillup_layer(names): # pylint: disable=arguments-differ
def fillup_layer(names):
"""
Creates a layer with InputWire elements.
Args:
@ -897,7 +897,6 @@ class Layer:
self.clbit_layer[self.cregs.index(clbit)] = element
def _set_multibox(self, wire_type, bits, label, top_connect=None):
# pylint: disable=invalid-name
bits = list(bits)
if wire_type == "cl":
bit_index = sorted([i for i, x in enumerate(self.cregs) if x in bits])

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=missing-docstring
"""
Initialize test.
"""

View File

@ -5,8 +5,6 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name
"""Quick program to test the qi tools modules."""
import json

View File

@ -39,7 +39,6 @@ class TestSimulatorsJob(QiskitTestCase):
job_id = str(uuid.uuid4())
backend = FakeRueschlikon()
# pylint: disable=invalid-name,redefined-outer-name
with mocked_executor() as (SimulatorJob, executor):
for index in range(taskcount):
job = SimulatorJob(backend, job_id, target_tasks[index], new_fake_qobj())
@ -59,7 +58,6 @@ class TestSimulatorsJob(QiskitTestCase):
job_id = str(uuid.uuid4())
backend = FakeRueschlikon()
# pylint: disable=invalid-name,redefined-outer-name
with mocked_executor() as (BasicAerJob, executor):
job = BasicAerJob(backend, job_id, lambda: None, new_fake_qobj())
job.submit()

View File

@ -5,7 +5,7 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name, unexpected-keyword-arg, no-value-for-parameter
# pylint: disable=invalid-name
"""Tests continuous pulse functions."""

View File

@ -5,8 +5,6 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name, unexpected-keyword-arg, no-value-for-parameter
"""Tests discrete sampled pulse functions."""
import numpy as np

View File

@ -5,7 +5,6 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name, unexpected-keyword-arg, no-value-for-parameter
"""Tests pulse function samplers."""

View File

@ -5,7 +5,7 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name,missing-docstring
# pylint: disable=invalid-name
"""Tests for quantum channel representation class."""
import numpy as np

View File

@ -5,7 +5,6 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name,missing-docstring
"""Equivalence tests for quantum channel methods."""
import unittest

View File

@ -5,7 +5,6 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name,missing-docstring
"""Tests for Chi quantum channel representation class."""
import unittest

View File

@ -5,7 +5,7 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name,missing-docstring
# pylint: disable=invalid-name
"""Tests for Choi quantum channel representation class."""
import unittest

View File

@ -5,7 +5,7 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name,missing-docstring
# pylint: disable=invalid-name
"""Tests for quantum channel representation transformations."""
import unittest

View File

@ -5,7 +5,6 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name,missing-docstring
"""Tests for Kraus quantum channel representation class."""
import unittest

View File

@ -5,7 +5,6 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name,missing-docstring
"""Equivalence tests for quantum channel methods."""
import unittest

View File

@ -5,7 +5,6 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name,missing-docstring
"""Tests for PTM quantum channel representation class."""
import unittest

View File

@ -5,7 +5,6 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name,missing-docstring
"""Tests for Stinespring quantum channel representation class."""
import unittest

View File

@ -5,7 +5,6 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name,missing-docstring
"""Tests for SuperOp quantum channel representation class."""
import unittest

View File

@ -5,7 +5,6 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name,missing-docstring
"""Equivalence tests for quantum channel methods."""
import unittest

View File

@ -5,7 +5,7 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name,missing-docstring
# pylint: disable=invalid-name
"""Tests for quantum channel representation transformations."""
import unittest

View File

@ -5,7 +5,7 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=invalid-name,missing-docstring
# pylint: disable=invalid-name
"""Tests for Operator matrix linear operator class."""
import unittest

View File

@ -12,7 +12,7 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name,missing-docstring
# pylint: disable=missing-docstring
"""Quick program to test the qi tools modules."""

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable=invalid-name
"""BasePass and generic pass testing"""
import unittest.mock

View File

@ -470,7 +470,7 @@ class TestUseCases(SchedulerTestCase):
class DoXTimesController(FlowController):
""" A control-flow plugin for running a set of passes an X amount of times."""
def __init__(self, passes, options, do_x_times=0, **_): # pylint: disable=super-init-not-called
def __init__(self, passes, options, do_x_times=0, **_):
self.do_x_times = do_x_times()
super().__init__(passes, options)

View File

@ -5,7 +5,7 @@
# This source code is licensed under the Apache License, Version 2.0 found in
# the LICENSE.txt file in the root directory of this source tree.
# pylint: disable=no-member,invalid-name,missing-docstring
# pylint: disable=missing-docstring
import unittest

View File

@ -12,8 +12,6 @@
# copyright notice, and modified files need to carry a notice indicating
# that they have been altered from the originals.
# pylint: disable = no-member
""" `_text_circuit_drawer` "draws" a circuit in "ascii art" """
from codecs import encode