Skip to content

Commit

Permalink
PEP8-linting complete.
Browse files Browse the repository at this point in the history
  • Loading branch information
thomashaener committed Mar 19, 2017
1 parent d265c65 commit 96564d7
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 42 deletions.
30 changes: 15 additions & 15 deletions docs/conf.py
Expand Up @@ -33,7 +33,7 @@
import sphinx_rtd_theme

extensions = [
'sphinx.ext.autodoc','sphinx.ext.napoleon', 'sphinx.ext.mathjax'
'sphinx.ext.autodoc', 'sphinx.ext.napoleon', 'sphinx.ext.mathjax'
]

# Add any paths that contain templates here, relative to this directory.
Expand Down Expand Up @@ -154,8 +154,8 @@
# html_logo = None

# The name of an image file (relative to this directory) to use as a favicon of
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
# pixels large.
# the docs. This file should be a Windows icon file (.ico) being 16x16 or 32x
# 32 pixels large.
#
# html_favicon = None

Expand Down Expand Up @@ -247,21 +247,21 @@
# -- Options for LaTeX output ---------------------------------------------

latex_elements = {
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',
# The paper size ('letterpaper' or 'a4paper').
#
# 'papersize': 'letterpaper',

# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',
# The font size ('10pt', '11pt' or '12pt').
#
# 'pointsize': '10pt',

# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',
# Additional stuff for the LaTeX preamble.
#
# 'preamble': '',

# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
# Latex figure (float) alignment
#
# 'figure_align': 'htbp',
}

# Grouping the document tree into LaTeX files. List of tuples
Expand Down
10 changes: 5 additions & 5 deletions examples/shor.py
Expand Up @@ -130,15 +130,15 @@ def high_level_gates(eng, cmd):
# try to determine the factors
if r % 2 != 0:
r *= 2
apowrhalf = pow(a, r>>1, N)
f1 = gcd(apowrhalf+1, N)
f2 = gcd(apowrhalf-1, N)
apowrhalf = pow(a, r >> 1, N)
f1 = gcd(apowrhalf + 1, N)
f2 = gcd(apowrhalf - 1, N)
if ((not f1 * f2 == N) and f1 * f2 > 1
and int(1. * N / (f1 * f2)) * f1 * f2 == N):
and int(1. * N / (f1 * f2)) * f1 * f2 == N):
f1, f2 = f1*f2, int(N/(f1*f2))
if f1 * f2 == N and f1 > 1 and f2 > 1:
print("\n\n\t\033[92mFactors found :-) : {} * {} = {}\033[0m"
.format(f1, f2, N))
.format(f1, f2, N))
else:
print("\n\n\t\033[91mBad luck: Found {} and {}\033[0m".format(f1,
f2))
Expand Down
12 changes: 6 additions & 6 deletions projectq/backends/_ibm/_ibm_http_client_test.py
Expand Up @@ -67,8 +67,8 @@ def raise_for_status(self):

# Accessing status of device. Return online.
if (args[0] == urljoin(_api_url_status, "Status/queue") and
kwargs["params"]["device"] == "chip_real" and
request_num[0] == 0):
kwargs["params"]["device"] == "chip_real" and
request_num[0] == 0):
request_num[0] += 1
return MockResponse({"state": True}, 200)
# Getting result
Expand Down Expand Up @@ -168,7 +168,7 @@ def json(self):

# Accessing status of device. Return online.
if (args[0] == urljoin(_api_url_status, "Status/queue") and
kwargs["params"]["device"] == "chip_real"):
kwargs["params"]["device"] == "chip_real"):
return MockResponse({"state": False}, 200)
monkeypatch.setattr("requests.get", mocked_requests_get)
shots = 1
Expand All @@ -193,7 +193,7 @@ def json(self):

# Accessing status of device. Return online.
if (args[0] == urljoin(_api_url_status, "Status/queue") and
kwargs["params"]["device"] == "chip_real"):
kwargs["params"]["device"] == "chip_real"):
return MockResponse({"state": True}, 200)

def mocked_requests_post(*args, **kwargs):
Expand Down Expand Up @@ -234,7 +234,7 @@ def json(self):

# Accessing status of device. Return online.
if (args[0] == urljoin(_api_url_status, "Status/queue") and
kwargs["params"]["device"] == "chip_real"):
kwargs["params"]["device"] == "chip_real"):
return MockResponse({"state": True}, 200)

def mocked_requests_post(*args, **kwargs):
Expand Down Expand Up @@ -275,7 +275,7 @@ def json(self):

# Accessing status of device. Return online.
if (args[0] == urljoin(_api_url_status, "Status/queue") and
kwargs["params"]["device"] == "chip_real"):
kwargs["params"]["device"] == "chip_real"):
return MockResponse({"state": True}, 200)

def mocked_requests_post(*args, **kwargs):
Expand Down
4 changes: 2 additions & 2 deletions projectq/backends/_sim/_simulator.py
Expand Up @@ -96,8 +96,8 @@ def is_available(self, cmd):
True if it can be simulated and False otherwise.
"""
if (cmd.gate == Measure or cmd.gate == Allocate
or cmd.gate == Deallocate
or isinstance(cmd.gate, BasicMathGate)):
or cmd.gate == Deallocate
or isinstance(cmd.gate, BasicMathGate)):
return True
try:
m = cmd.gate.matrix
Expand Down
1 change: 0 additions & 1 deletion projectq/setups/__init__.py
Expand Up @@ -9,4 +9,3 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

1 change: 0 additions & 1 deletion projectq/setups/decompositions/__init__.py
Expand Up @@ -9,4 +9,3 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

8 changes: 4 additions & 4 deletions projectq/setups/decompositions/_gates_test.py
Expand Up @@ -43,7 +43,7 @@ def low_level_gates(eng, cmd):
return True
if len(cmd.control_qubits) == 0:
if (g == T or g == Tdag or g == H or isinstance(g, Rz)
or isinstance(g, Ph)):
or isinstance(g, Ph)):
return True
else:
if len(cmd.control_qubits) == 1 and cmd.gate == X:
Expand All @@ -70,8 +70,8 @@ def low_level_gates_noglobalphase(eng, cmd):

def test_globalphase():
dummy = DummyEngine(save_commands=True)
eng = MainEngine(dummy, [AutoReplacer(),
InstructionFilter(low_level_gates_noglobalphase)])
filter_engine = InstructionFilter(low_level_gates_noglobalphase)
eng = MainEngine(dummy, [AutoReplacer(), filter_engine])

qubit = eng.allocate_qubit()
R(1.2) | qubit
Expand Down Expand Up @@ -105,7 +105,7 @@ def test_gate_decompositions():

sim2 = Simulator()
eng_lowlevel = MainEngine(sim2, [AutoReplacer(),
InstructionFilter(low_level_gates)])
InstructionFilter(low_level_gates)])
qureg2 = run_circuit(eng_lowlevel)

for i in range(len(sim.cheat()[1])):
Expand Down
19 changes: 11 additions & 8 deletions setup.py
Expand Up @@ -11,6 +11,7 @@
# Readme file as long_description:
long_description = open('README.rst').read()


class get_pybind_include(object):
"""Helper class to determine the pybind11 include path
Expand All @@ -33,7 +34,7 @@ def __str__(self):
Extension(
'projectq.backends._sim._cppsim',
['projectq/backends/_sim/_cppsim.cpp'],
include_dirs=[
include_dirs=[
# Path to pybind11 headers
get_pybind_include(),
get_pybind_include(user=True)
Expand Down Expand Up @@ -110,7 +111,7 @@ def build_extensions(self):
elif has_flag(self.compiler, '-openmp'):
openmp = '-openmp'
if ct == 'msvc':
openmp = '' # supports only OpenMP 2.0
openmp = '' # supports only OpenMP 2.0

if knows_intrinsics(self.compiler):
opts.append('-DINTRIN')
Expand All @@ -125,12 +126,14 @@ def build_extensions(self):
self.warning("Compiler needs to have C++11 support!")
return

opts.append('-DVERSION_INFO="%s"' % self.distribution.get_version())
opts.append('-DVERSION_INFO="%s"'
% self.distribution.get_version())
opts.append('-std=c++11')
if has_flag(self.compiler, '-fvisibility=hidden'):
opts.append('-fvisibility=hidden')
elif ct == 'msvc':
opts.append('/DVERSION_INFO=\\"%s\\"' % self.distribution.get_version())
opts.append('/DVERSION_INFO=\\"%s\\"'
% self.distribution.get_version())
for ext in self.extensions:
ext.extra_compile_args = opts
ext.extra_link_args = [openmp]
Expand All @@ -142,8 +145,8 @@ def build_extensions(self):
def warning(self, warning_text):
Exception(warning_text + "\nCould not install the C++-Simulator.\n"
"ProjectQ will default to the (slow) Python simulator.\n"
"Use --without-cppsimulator to skip building the (faster) C++"
" version of the simulator.")
"Use --without-cppsimulator to skip building the (faster) "
"C++ version of the simulator.")


setup(
Expand All @@ -153,11 +156,11 @@ def warning(self, warning_text):
author_email='info@projectq.ch',
url='http://www.projectq.ch',
description=('ProjectQ - '
'An open source software framework for quantum computing'),
'An open source software framework for quantum computing'),
long_description=long_description,
features={'cppsimulator': cppsim},
install_requires=['numpy', 'future', 'pytest>=3.0',
'pybind11>=1.7','requests'],
'pybind11>=1.7', 'requests'],
cmdclass={'build_ext': BuildExt},
zip_safe=False,
license='Apache 2',
Expand Down

0 comments on commit 96564d7

Please sign in to comment.