Repository: XanaduAI/flamingpy (language: python)

Issue:
Removing Cythonization example when no longer needed
* Adding an example integrated cython file and new setup step were only done as a guiding step for first performance improvement cythonization. If a functional cython file exists or it is unlikely we use cythonization for now, we have to fully remove this example to avoid overcomplicating and adding an unused component to FP.

https://github.com/XanaduAI/flamingpy/blob/main/flamingpy/cpp/cpp_mc_loop.pyx


Discussion / hints:

Fix patch:
diff --git a/.github/CHANGELOG.md b/.github/CHANGELOG.md
index 28b43656..af803819 100644
--- a/.github/CHANGELOG.md
+++ b/.github/CHANGELOG.md
@@ -1,10 +1,30 @@
-## Release 0.9.1b0 (development release)
+## Release 0.10.1b1 (development release)
 
 ### New features since the last release
 
-* Add `is_lc_equivalent` method to the EGraph class to check if two EGraphs are equivalent under local complementation, as well as related linear algebra helper functions inside `utils\linalg.py`. [#89](https://github.com/XanaduAI/flamingpy/pull/89), [#117](https://github.com/XanaduAI/flamingpy/pull/117)
- * Add functions `add_qubit` and `remove_qubit` to the `EGraph` class, which allow adding and removing nodes of the EGraph while updating internal attributes of the class. [#10](https://github.com/XanaduAI/flamingpy/pull/100).
-* The I/O of frontend `simulations.py` has been improved. The input has been simplified to an intuitive set of `code`, `code_args`, `noise`, and `noise_args`. As long as those combinations are valid, FlamingPy will run simulations and automatically set up the output file based on inputs. [#111](https://github.com/XanaduAI/flamingpy/pull/111) (backward incompatible)
+### Bug fixes
+
+### Improvements
+
+### Documentation changes
+
+### Contributors
+
+This release contains contributions from (in alphabetical order):
+
+See full commit details ...
+
+
+---
+
+## Release 0.10.1b1 (current release)
+
+### New features since the last release
+
+* Add `is_lc_equivalent` method to the EGraph class to check if two EGraphs are equivalent under local complementation, as well as related linear algebra helper functions inside `utils\linalg.py`. [#89](https://github.com/XanaduAI/flamingpy/pull/89), [#117](https://github.com/XanaduAI/flamingpy/pull/117) (backward compatible)
+* Add functions `add_qubit` and `remove_qubit` to the `EGraph` class, which allow adding and removing nodes of the EGraph while updating internal attributes of the class. [#100](https://github.com/XanaduAI/flamingpy/pull/100) (backward compatible)
+* Added Plotly backend for visualizing graph states. [#103](https://github.com/XanaduAI/flamingpy/pull/103)
+* The I/O of frontend `simulations.py` has been improved. The input has been simplified to an intuitive set of `code`, `code_args`, `noise`, and `noise_args`. As long as those combinations are valid, FlamingPy will run simulations and automatically set up the output file based on the input. [#111](https://github.com/XanaduAI/flamingpy/pull/111) (backward incompatible)
   * An example run will be 
     ```
     python flamingpy/simulations.py -code "SurfaceCode" -code_args "{'distance':3, 'ec':'primal', 'boundaries':'open'}" -noise "CVLayer" -noise_args "{'delta':0.09, 'p_swap':0.25}" -decoder "MWPM" -decoder_args "{'weight_opts':{'method':'blueprint', 'integer':False, 'multiplier':1, 'delta':0.09}}" -trials 100
@@ -14,19 +34,19 @@
     code,distance,ec,boundaries,noise,delta,p_swap,decoder,weight_opts,errors,trials,current_time,simulation_time,mpi_size
     SurfaceCode,3,primal,open,CVLayer,0.09,0.25,MWPM,{'method': 'blueprint', 'integer': False, 'multiplier': 1, 'delta': 0.09},10,100,00:15:50,0.370795,1
     ```
-* Added Plotly backend for visualizing graph states. [#103](https://github.com/XanaduAI/flamingpy/pull/103)
-* Users can install FlamingPy from git with pip. [#118](https://github.com/XanaduAI/flamingpy/pull/118)
+* Users can now install FlamingPy from `git` with `pip`. This also means installing through `python setup.py egg_info` is now valid. [#118](https://github.com/XanaduAI/flamingpy/pull/118) (backward compatible)
 
 ### Bug fixes
 
-* `dev_requirements` was updated with the latest version of `docformatter` to prevent failing tests. [#116](https://github.com/XanaduAI/flamingpy/pull/116)
+* `dev_requirements` was updated with the latest version of `docformatter` to prevent failing unit tests. [#116](https://github.com/XanaduAI/flamingpy/pull/116)
 
 ### Improvements
 
+* Cython example code, `cpp_mc_loop.pyx`, and its installation instructions were removed from everywhere as it was unused. New developers can refer to historic commits to help add new Cython files. [#119](https://github.com/XanaduAI/flamingpy/pull/119)    
 
 ### Documentation changes
 
-* `give_for_devs.rst` was updated to match the latest `dev_requirements` file. [#116](https://github.com/XanaduAI/flamingpy/pull/116)
+* `give_for_devs.rst` was updated to match the latest `dev_requirements` file and deletion of the Cython example. [#116](https://github.com/XanaduAI/flamingpy/pull/116), [#119](https://github.com/XanaduAI/flamingpy/pull/119)
 
 ### Contributors
 
@@ -34,12 +54,10 @@ This release contains contributions from (in alphabetical order):
 
 [Joost Bus](https://github.com/soosub), [Luis Mantilla](https://github.com/BestQuark), [Avhijit Nair](https://github.com/Avhijit-codeboy), Nariman Saadatmand, [smtsjhr](https://github.com/smtsjhr), [Ilan Tzitrin](https://github.com/ilan-tz)
 
-See full commit details ...
+See full commit details [here](https://github.com/XanaduAI/flamingpy/compare/v0.9.1b0...0.10.1b1).
 
 
----
-
-## Release 0.9.1b0 (current release)
+## Release 0.9.1b0
 
 ### Bug fixes since the last release
 
diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml
index 895dcdb8..9f1800d8 100644
--- a/.github/workflows/docs.yaml
+++ b/.github/workflows/docs.yaml
@@ -15,8 +15,11 @@ jobs:
     steps:
     - uses: actions/checkout@v1
 
+    - name: Get the latest pip
+      run: python -m pip install --upgrade pip
+
     - name: Build sphinx documentation
       uses: XanaduAI/sphinx-action@master
       with:
         docs-folder: "doc/"
-        pre-build-command: "apt install -y build-essential graphviz git && python -m pip install --upgrade pip && python -m pip install -r doc/dev_requirements.txt && python setup.py develop"
+        pre-build-command: "apt install -y build-essential graphviz git && python -m pip install -r doc/dev_requirements.txt && python setup.py develop"
diff --git a/.github/workflows/upload_linux_x64.yaml b/.github/workflows/upload_linux_x64.yaml
index d00ada6c..b9a0139a 100644
--- a/.github/workflows/upload_linux_x64.yaml
+++ b/.github/workflows/upload_linux_x64.yaml
@@ -35,7 +35,6 @@ jobs:
       - name: Build flamingpy from Source
         run: |
           python setup.py develop
-          python setup.py build_cython --inplace
           python setup.py build_cmake --inplace
 
       - name: Run tests
diff --git a/.github/workflows/upload_macos_x64.yaml b/.github/workflows/upload_macos_x64.yaml
index 3434c12f..40aa5ecf 100644
--- a/.github/workflows/upload_macos_x64.yaml
+++ b/.github/workflows/upload_macos_x64.yaml
@@ -38,7 +38,6 @@ jobs:
       - name: Build flamingpy from Source
         run: |
           python setup.py develop
-          python setup.py build_cython --inplace
           python setup.py build_cmake --inplace
 
       - name: Run tests
diff --git a/.github/workflows/upload_win_x64.yaml b/.github/workflows/upload_win_x64.yaml
index 7cf13c85..a20caa44 100644
--- a/.github/workflows/upload_win_x64.yaml
+++ b/.github/workflows/upload_win_x64.yaml
@@ -44,7 +44,6 @@ jobs:
       - name: Build flamingpy from Source
         run: |
           python setup.py develop
-          python setup.py build_cython --inplace
           python setup.py build_cmake --inplace
 
       - name: Run tests
diff --git a/.gitignore b/.gitignore
index 56825c44..634c4c12 100644
--- a/.gitignore
+++ b/.gitignore
@@ -151,9 +151,5 @@ dmypy.json
 # pytype static type analyzer
 .pytype/
 
-# Cython stuff
-cython_debug/
-flamingpy/cpp/cpp_mc_loop.cpp
-
 # VSCode stuff
 .vscode/
diff --git a/README.md b/README.md
index 28311a28..5d9b06de 100644
--- a/README.md
+++ b/README.md
@@ -67,14 +67,13 @@ Finally, change to the directory where FlamingPy was cloned and run:
 ```bash
 python -m pip install -r dev_requirements.txt
 python setup.py develop # only installs Python libraries
-python setup.py build_cython --inplace # [OPTIONAL] compiles Cython-based backends
 python setup.py build_cmake --inplace # [OPTIONAL] compiles CMake-based backends
 ```
 
 Note you will need to remove the comments manually if you use Windows prompt. The purpose of the commands is as follows:
 - The first command installs dependencies for building the project and testing purposes, and can be skipped if already satisfied. 
 - The second command (develop) installs FlamingPy Python libraries without compiling the optional backends. 
-- The next optional commands compile various FlamingPy backends as required (given you have appropriate compilers pre-installed). 
+- The next optional command compiles various FlamingPy backends as required (given you have appropriate compilers pre-installed). 
 
 If you encountered **CMake** errors, you may need to (re-)install it through `conda install cmake` or other means before re-attempting the above. Furthermore, you may wish to try `conda install git` for **git**-related errors. 
 
diff --git a/dev_requirements.txt b/dev_requirements.txt
index 906ef7e4..05af5151 100644
--- a/dev_requirements.txt
+++ b/dev_requirements.txt
@@ -1,7 +1,6 @@
 black>=19.3b0
 cmake>=3.14
 codecov>=2.1.12
-cython>=0.29.28
 docformatter>=1.5
 matplotlib>=3.3.3
 networkx>=2.5
diff --git a/doc/dev_requirements.txt b/doc/dev_requirements.txt
index e9d0b0ed..920aa4d8 100644
--- a/doc/dev_requirements.txt
+++ b/doc/dev_requirements.txt
@@ -1,18 +1,18 @@
-docutils>=0.15.2
-m2r2>=0.3.2
-matplotlib>=3.3.3
-networkx>=2.5
-numba>=0.53.1
-numpy>=1.21
-pylint>=2.13.9
-retworkx>=0.10.2
-scipy>=1.6
-sphinx==4.4.0 # the newer sphinx==5.0.0 has known problems handling quotes for embedding hyperlinks 
-sphinx-autodoc-typehints>=1.10.3
-sphinx-automodapi>=0.13
-sphinx-copybutton>=0.4
-sphinxcontrib-bibtex>=0.4.2
-thewalrus>=0.19.0
-toml>=0.10.2
-xanadu-sphinx-theme>=0.1.0
+docutils>=0.15.2
+m2r2>=0.3.2
+matplotlib>=3.3.3
+networkx>=2.5
+numba>=0.53.1
+numpy>=1.21
+pylint>=2.13.9
+retworkx>=0.10.2
+scipy>=1.6
+sphinx==4.4.0 # the newer sphinx==5.0.0 has known problems handling quotes for embedding hyperlinks 
+sphinx-autodoc-typehints>=1.10.3
+sphinx-automodapi>=0.13
+sphinx-copybutton>=0.4
+sphinxcontrib-bibtex>=0.4.2
+thewalrus>=0.19.0
+toml>=0.10.2
+xanadu-sphinx-theme>=0.1.0
 plotly>=4.5.0
\ No newline at end of file
diff --git a/doc/development/guide_for_devs.rst b/doc/development/guide_for_devs.rst
index cf756485..7aaa5939 100644
--- a/doc/development/guide_for_devs.rst
+++ b/doc/development/guide_for_devs.rst
@@ -13,7 +13,6 @@ as well as the following Python packages for development purposes:
 * |black| >= 19.3b0
 * |cmake| >= 3.14
 * |codecov| >= 2.1.12
-* |cython| >= 0.29.28
 * |docformatter| >= 1.5
 * |matplotlib| >= 3.3.3
 * |mpi4py| >= 3.1.3 (optional, only for Linux users)
@@ -85,7 +84,6 @@ To install FlamingPy from Source, next change to the directory where FlamingPy w
 .. code-block:: bash
 
     python setup.py develop # only installs Python libraries
-    python setup.py build_cython --inplace # [OPTIONAL] compiles Cython-based backends
     python setup.py build_cmake --inplace # [OPTIONAL] compiles CMake-based backends
 
 The purpose of the commands is as follows:
@@ -148,10 +146,6 @@ See :doc:`build_docs` for the details on how to build the HTML documentation.
 
    <a href="https://about.codecov.io/language/python/" target="_blank">codecov</a>
 
-.. |cython| raw:: html
-
-   <a href="https://cython.org/" target="_blank">cython</a>
-
 .. |docformatter| raw:: html
 
    <a href="https://pypi.org/project/docformatter/" target="_blank">docformatter</a>
diff --git a/doc/install.rst b/doc/install.rst
index 6aad97c7..d4989230 100644
--- a/doc/install.rst
+++ b/doc/install.rst
@@ -76,7 +76,6 @@ Installation
     python -m pip install -r dev_requirements.txt
     # Choose one or some of the following:
     python setup.py develop # Only install Python libraries.
-    python setup.py build_cython --inplace # Compile Cython-based backends.
     python setup.py build_cmake --inplace # Compile CMake-based backends.
                     </code>
                 </pre>
diff --git a/flamingpy/_version.py b/flamingpy/_version.py
index 4abc7c87..f5281027 100644
--- a/flamingpy/_version.py
+++ b/flamingpy/_version.py
@@ -14,4 +14,4 @@
 """Version number (major.minor.patch[label])"""
 
 
-__version__ = "0.9.1b0.dev5"
+__version__ = "0.10.1b1"
diff --git a/flamingpy/cpp/cpp_mc_loop.pyx b/flamingpy/cpp/cpp_mc_loop.pyx
deleted file mode 100644
index 78ee429b..00000000
--- a/flamingpy/cpp/cpp_mc_loop.pyx
+++ /dev/null
@@ -1,26 +0,0 @@
-# Copyright 2022 Xanadu Quantum Technologies Inc.
-
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-
-#     http://www.apache.org/licenses/LICENSE-2.0
-
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# 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.
-"""Cython-based Monte Carlo simulations for estimating FT thresholds."""
-from flamingpy.decoders.decoder import correct
-
-cpdef int cpp_mc_loop(int trials, object code_instance, object noise_instance, dict decoder, dict weight_options):
-    """Exclusively run loop section of Monte Carlo simulations of error-correction on code=code."""
-    cdef int successes = 0
-    cdef int result, errors, ii
-    for ii in range(trials):
-        noise_instance.apply_noise()
-        result = correct(code=code_instance, decoder=decoder, weight_options=weight_options)
-        successes += result
-    errors = trials - successes
-    return errors
diff --git a/setup.py b/setup.py
index 6673baa2..8772c296 100644
--- a/setup.py
+++ b/setup.py
@@ -112,16 +112,7 @@ def build_extension(self, ext):
 
 
 # setup parameters
-if sys.argv[1] == "build_cython":
-    ext_modules = [
-        Extension(
-            "flamingpy.cpp.cpp_mc_loop",
-            sources=["flamingpy/cpp/cpp_mc_loop.pyx"],
-            extra_compile_args=["-O3", "-w"],
-            language="c++",
-        )
-    ]
-elif sys.argv[1] == "build_cmake":
+if sys.argv[1] == "build_cmake":
     ext_modules = [CMakeExtension("flamingpy.cpp.lemonpy")]
 elif sys.argv[1] in ("install", "develop", "bdist_wheel", "egg_info"):
     ext_modules = []
@@ -179,7 +170,6 @@ def build_extension(self, ext):
     cmdclass={
         "install": install,
         "develop": develop,
-        "build_cython": build_ext,
         "build_cmake": CMakeBuild,
     },
     ext_modules=ext_modules,


Test patch:
diff --git a/.github/workflows/build_tests.yaml b/.github/workflows/build_tests.yaml
index fc501b7d..e1d6a870 100644
--- a/.github/workflows/build_tests.yaml
+++ b/.github/workflows/build_tests.yaml
@@ -26,6 +26,7 @@ jobs:
 
     env:
       USE_MPI: ${{ matrix.config.use_mpi }}
+      # Please retain a cov score of ~96% to avoid unit tests marginally failing.
       COVERAGE_FLAGS: "--cov=flamingpy --cov-report=xml --cov-report=term-missing --cov-fail-under=95"
       XDIST_FLAGS: "-n auto --dist=loadfile"
 
@@ -51,7 +52,6 @@ jobs:
       - name: Build flamingpy from Source
         run: |
           python setup.py develop
-          python setup.py build_cython --inplace
           python setup.py build_cmake --inplace
 
       - name: Run tests