diff --git a/docs/conf.py b/docs/conf.py index 7c0c1bac9..435ff5187 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -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. @@ -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 @@ -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 diff --git a/examples/shor.py b/examples/shor.py index be103fdfd..a014e3d8e 100755 --- a/examples/shor.py +++ b/examples/shor.py @@ -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)) diff --git a/projectq/backends/_ibm/_ibm_http_client_test.py b/projectq/backends/_ibm/_ibm_http_client_test.py index f8cb83f70..dd9081b86 100755 --- a/projectq/backends/_ibm/_ibm_http_client_test.py +++ b/projectq/backends/_ibm/_ibm_http_client_test.py @@ -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 @@ -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 @@ -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): @@ -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): @@ -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): diff --git a/projectq/backends/_sim/_simulator.py b/projectq/backends/_sim/_simulator.py index 5fa364326..f9fec614d 100755 --- a/projectq/backends/_sim/_simulator.py +++ b/projectq/backends/_sim/_simulator.py @@ -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 diff --git a/projectq/setups/__init__.py b/projectq/setups/__init__.py index fac912ea7..53f003f0a 100755 --- a/projectq/setups/__init__.py +++ b/projectq/setups/__init__.py @@ -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. - diff --git a/projectq/setups/decompositions/__init__.py b/projectq/setups/decompositions/__init__.py index fac912ea7..53f003f0a 100755 --- a/projectq/setups/decompositions/__init__.py +++ b/projectq/setups/decompositions/__init__.py @@ -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. - diff --git a/projectq/setups/decompositions/_gates_test.py b/projectq/setups/decompositions/_gates_test.py index eebb3658f..a9c555c3f 100755 --- a/projectq/setups/decompositions/_gates_test.py +++ b/projectq/setups/decompositions/_gates_test.py @@ -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: @@ -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 @@ -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])): diff --git a/setup.py b/setup.py index 6a8237aec..7559c1060 100755 --- a/setup.py +++ b/setup.py @@ -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 @@ -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) @@ -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') @@ -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] @@ -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( @@ -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',