Skip to content

Commit

Permalink
Apply the Black code style to the source code (#95)
Browse files Browse the repository at this point in the history
* Apply the Black code style

* Disable pep8 E203 check in code climate

* Add lint check to GitHub action

* Add black configuration for the max line length
  • Loading branch information
BoxiLi committed Sep 29, 2021
1 parent 77a3a48 commit 527c3c8
Show file tree
Hide file tree
Showing 28 changed files with 3,056 additions and 1,647 deletions.
3 changes: 3 additions & 0 deletions .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ plugins:
enabled: true
pep8:
enabled: true
checks:
E203:
enabled: false
duplication:
enabled: true
config:
Expand Down
13 changes: 13 additions & 0 deletions .github/workflows/black.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Lint

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: psf/black@stable
with:
options: "--check --diff"
src: "./src"
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ requires = [
"wheel",
]
build-backend = "setuptools.build_meta"

[tool.black]
line-length = 79
17 changes: 11 additions & 6 deletions src/qutip_qip/algorithms/qft.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from qutip import Qobj


__all__ = ['qft', 'qft_steps', 'qft_gate_sequence']
__all__ = ["qft", "qft_steps", "qft_gate_sequence"]


def qft(N=1):
Expand Down Expand Up @@ -67,8 +67,9 @@ def qft_steps(N=1, swapping=True):
else:
for i in range(N):
for j in range(i):
U_step_list.append(cphase(np.pi / (2 ** (i - j)), N,
control=i, target=j))
U_step_list.append(
cphase(np.pi / (2 ** (i - j)), N, control=i, target=j)
)
U_step_list.append(snot(N, i))
if swapping:
for i in range(N // 2):
Expand Down Expand Up @@ -104,9 +105,13 @@ def qft_gate_sequence(N=1, swapping=True):
else:
for i in range(N):
for j in range(i):
qc.add_gate("CPHASE", targets=[j], controls=[i],
arg_label=r"{\pi/2^{%d}}" % (i - j),
arg_value=np.pi / (2 ** (i - j)))
qc.add_gate(
"CPHASE",
targets=[j],
controls=[i],
arg_label=r"{\pi/2^{%d}}" % (i - j),
arg_value=np.pi / (2 ** (i - j)),
)
qc.add_gate("SNOT", targets=[i])
if swapping:
for i in range(N // 2):
Expand Down

0 comments on commit 527c3c8

Please sign in to comment.