Skip to content

Commit

Permalink
Enable a reduced set of pylint checks (#146)
Browse files Browse the repository at this point in the history
* Enable a reduced set of pylint checks

* Fix typo

* Remove duplicate nbqa

* Bump pylint version

* Update module location

* Fix redefined builtin

> circuit_knitting/cutting/cutqc/wire_cutting.py:226:4: W0622: Redefining built-in 'bin' (redefined-builtin)
  • Loading branch information
garrison authored Sep 13, 2023
1 parent 5224cda commit 6bb6fec
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 21 deletions.
4 changes: 1 addition & 3 deletions circuit_knitting/cutting/cutqc/wire_cutting.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def create_dd_bin(
subcircuit_entries, subcircuit_instance_probabilities
)

bin = dd_build(
return dd_build(
summation_terms=summation_terms,
subcircuit_entry_probs=subcircuit_entry_probabilities,
num_cuts=cuts["num_cuts"],
Expand All @@ -234,8 +234,6 @@ def create_dd_bin(
num_threads=num_threads,
)

return bin


def reconstruct_dd_full_distribution(
circuit: QuantumCircuit,
Expand Down
21 changes: 12 additions & 9 deletions circuit_knitting/forging/entanglement_forging_ansatz.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,15 @@ def subspace_dimension(self) -> int:

def __repr__(self) -> str:
"""Representation function for EntanglementForgingAnsatz."""
repr = "EntanglementForgingAnsatz\nCircuit:\n"
repr += str(self._circuit_u.draw())
repr += "\nBitstrings U:\n"
repr += str(self.bitstrings_u)
repr += "\nBitstrings V:\n"
repr += str(self._bitstrings_v)
repr += f"\nBitstring are symmetric: {self.bitstrings_are_symmetric}\n"
repr += f"Subspace dimension: {self.subspace_dimension}"
return repr
return "".join(
(
"EntanglementForgingAnsatz\nCircuit:\n",
str(self._circuit_u.draw()),
"\nBitstrings U:\n",
str(self.bitstrings_u),
"\nBitstrings V:\n",
str(self._bitstrings_v),
f"\nBitstring are symmetric: {self.bitstrings_are_symmetric}\n",
f"Subspace dimension: {self.subspace_dimension}",
)
)
21 changes: 12 additions & 9 deletions circuit_knitting/forging/entanglement_forging_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,15 @@ def __repr__(self) -> str:
Returns:
Printable representation of class
"""
repr = "EntanglementForgingOperator\nTensor Paulis:\n"
repr += str(self.tensor_paulis)
repr += "\nSuperposition Paulis:\n"
repr += str(self.superposition_paulis)
repr += "\nTensor Weight Matrix:\n"
repr += np.array_str(self.w_ij, precision=4, suppress_small=True)
repr += "\nSuperposition Weight Matrix:\n"
repr += np.array_str(self.w_ab, precision=4, suppress_small=True)
return repr
return "".join(
(
"EntanglementForgingOperator\nTensor Paulis:\n",
str(self.tensor_paulis),
"\nSuperposition Paulis:\n",
str(self.superposition_paulis),
"\nTensor Weight Matrix:\n",
np.array_str(self.w_ij, precision=4, suppress_small=True),
"\nSuperposition Weight Matrix:\n",
np.array_str(self.w_ab, precision=4, suppress_small=True),
)
)
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ lint = [
"pydocstyle==6.3.0",
"mypy==1.5.1",
"reno>=3.4.0",
"pylint==2.17.5",
# pydocstyle prefers to parse our pyproject.toml, hence the following line
"toml",
]
Expand Down
2 changes: 2 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ commands =
pydocstyle circuit_knitting/ circuit_knitting_toolbox/
mypy circuit_knitting/ circuit_knitting_toolbox/
reno lint
pylint -rn --py-version=3.8 --disable=all --enable=reimported,no-self-use,no-else-raise,redefined-argument-from-local,redefined-builtin,raise-missing-from,cyclic-import circuit_knitting/ test/ tools/
nbqa pylint -rn --py-version=3.8 --disable=all --enable=reimported,no-self-use,no-else-raise,redefined-argument-from-local,redefined-builtin,raise-missing-from,cyclic-import docs/

[testenv:{,py-,py3-,py38-,py39-,py310-,py311-}notebook]
extras =
Expand Down

0 comments on commit 6bb6fec

Please sign in to comment.