Skip to content

Commit

Permalink
Merge branch 'kz-dev' into 'master'
Browse files Browse the repository at this point in the history
dev: Added `flake8` linter tool

See merge request wigner-rcp-quantum-computing-and-information-group/piquasso!11
  • Loading branch information
kolarovszki-elte committed Aug 5, 2020
2 parents b9d9917 + 3a44627 commit ceeda71
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 14 deletions.
5 changes: 2 additions & 3 deletions piquasso/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import numpy as np

from piquasso.context import Context
from piquasso.operator import BaseOperator


Expand All @@ -27,8 +26,8 @@ def beamsplitter(self, params, modes):
modes [int]: modes to operate on
Returns:
(numpy.ndarray): The representation of the one-particle beamsplitter gate
on modes `i` and `j`.
(numpy.ndarray): The representation of the one-particle
beamsplitter gate on modes `i` and `j`.
"""

theta, phi = params
Expand Down
4 changes: 3 additions & 1 deletion piquasso/gates.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ def resolve_method_for_backend(self):
method = self.backends.get(Context.current_program.backend.__class__)

if not method:
raise NotImplementedError("No such operation implemented on this backend.")
raise NotImplementedError(
"No such operation implemented on this backend."
)

return method

Expand Down
13 changes: 9 additions & 4 deletions piquasso/mode.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@

class Q:
"""
The implementation of qumodes, which is used to track on which qumodes are the
operators placed in the circuit.
The implementation of qumodes, which is used to track on which qumodes are
the operators placed in the circuit.
"""
def __init__(self, *modes):
"""
Args:
modes: The positive integer values which is used to represent the qumodes.
modes: The positive integer values which is used to represent the
qumodes.
"""
self.modes = modes

Expand All @@ -27,6 +28,10 @@ def __or__(self, gate):
(Q): The current qumode.
"""
Context.current_program.instructions.append(
{'params': gate.params, 'modes': self.modes, 'op': gate.resolve_method_for_backend()}
{
'params': gate.params,
'modes': self.modes,
'op': gate.resolve_method_for_backend()
}
)
return self
3 changes: 2 additions & 1 deletion piquasso/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
class Program:
"""The representation for a quantum program.
This also specifies a context in which all the operations should be specified.
This also specifies a context in which all the operations should be
specified.
"""

def __init__(self, state, backend):
Expand Down
64 changes: 60 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ authors = ["Zoltán Kolarovszki"]
[tool.poetry.dependencies]
python = "^3.6"
numpy = "^1.19.0"
flake8 = "^3.8.3"

[tool.poetry.dev-dependencies]
pytest = "^5.2"
Expand Down
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ isolated_build = True
whitelist_externals = poetry
commands =
poetry install -v
poetry run pytest tests/
poetry run pytest
poetry run flake8

[tox:.package]
basepython = python3

0 comments on commit ceeda71

Please sign in to comment.