diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index d1c6592..0000000 --- a/.coveragerc +++ /dev/null @@ -1,2 +0,0 @@ -[run] -omit = forestopenfermion/*_test.py \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml new file mode 100644 index 0000000..2d24cbf --- /dev/null +++ b/.gitlab-ci.yml @@ -0,0 +1,8 @@ +image: python:3.6 + +test: + tags: + - github + script: + - pip install -r requirements.txt + - pytest diff --git a/MANIFEST.in b/MANIFEST.in index 01f84eb..add1c9e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,5 @@ include LICENSE +include NOTICE include README.md include requirements.txt include VERSION.txt diff --git a/README.md b/README.md index 35d75a7..6f07da7 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,15 @@ The Rigetti Forest Plugin for OpenFermion ========================================= +> **NOTE**: This repository is not being actively developed at Rigetti, and therefore we have +decided to archive it. It should work in its current state, but if you find issues or would like +to suggest that we re-open development on this project (or, even better, if you would like to +develop it!) please send us an email at [software@rigetti.com](mailto:software@rigetti.com). + +[![pipeline status](https://gitlab.com/rigetti/forest/forest-openfermion/badges/master/pipeline.svg)](https://gitlab.com/rigetti/forest/forest-openfermion/commits/master) [![Build Status][semaphore-badge]][semaphore-project] -[OpenFermion](http://openfermion.org) is an open source package for compiling and analyzing +[OpenFermion](http://openfermion.org) is an open-source package for compiling and analyzing quantum algorithms that simulate fermionic systems. This plugin library allows the circuit construction and simulation environment [Forest](http://www.rigetti.com/forest) to interface with OpenFermion. @@ -26,13 +32,13 @@ pip install -e . Alternatively, one can install the last major release from PyPI via: ```bash -pip install forestopenfermion +pip install forest-openfermion ``` Development and Testing ----------------------- -We use `pytest` for testing. Tests can be executed from the top-level directory by simply running: +Tests can be executed from the top-level directory by simply running: ```bash pytest diff --git a/forest/__init__.py b/forest/__init__.py new file mode 100644 index 0000000..69e3be5 --- /dev/null +++ b/forest/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/forest/openfermion/__init__.py b/forest/openfermion/__init__.py new file mode 100644 index 0000000..0939c88 --- /dev/null +++ b/forest/openfermion/__init__.py @@ -0,0 +1,30 @@ +# 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. + +from forest.openfermion.pyquil_circuit_generator import exponentiate, TimeEvolution + +from forest.openfermion.pyquil_connector import pyquilpauli_to_qubitop, qubitop_to_pyquilpauli + +from forest.openfermion.rdm_estimation import (pauli_terms_for_tpdm, + pauli_to_tpdm, + pauli_terms_for_tpdm_aa, + pauli_terms_for_tpdm_bb, + pauli_terms_for_tpdm_ab, + pauli_to_tpdm_aa, + pauli_to_tpdm_bb, + pauli_to_tpdm_ab) + +from forest.openfermion.rdm_utilities import (get_sz_spin_adapted, + unspin_adapt, + pauli_term_from_string, + pauli_term_relabel, + pauli_dict_relabel) diff --git a/forestopenfermion/pyquil_circuit_generator.py b/forest/openfermion/pyquil_circuit_generator.py similarity index 97% rename from forestopenfermion/pyquil_circuit_generator.py rename to forest/openfermion/pyquil_circuit_generator.py index 779b8f8..90af957 100644 --- a/forestopenfermion/pyquil_circuit_generator.py +++ b/forest/openfermion/pyquil_circuit_generator.py @@ -16,12 +16,12 @@ """ An interface from OpenFermion QubitObjects to some of the circuit generating functionality in pyquil """ -from forestopenfermion.pyquil_connector import qubitop_to_pyquilpauli from openfermion.ops import QubitOperator - from pyquil.quil import Program from pyquil.paulis import exponentiate as pyquil_exponentiate +from forest.openfermion.pyquil_connector import qubitop_to_pyquilpauli + def exponentiate(qubit_operator): """ diff --git a/forestopenfermion/pyquil_connector.py b/forest/openfermion/pyquil_connector.py similarity index 100% rename from forestopenfermion/pyquil_connector.py rename to forest/openfermion/pyquil_connector.py diff --git a/forestopenfermion/rdm_estimation.py b/forest/openfermion/rdm_estimation.py similarity index 98% rename from forestopenfermion/rdm_estimation.py rename to forest/openfermion/rdm_estimation.py index 6fa65a6..e6a3c7d 100644 --- a/forestopenfermion/rdm_estimation.py +++ b/forest/openfermion/rdm_estimation.py @@ -1,19 +1,18 @@ """ A module for generating pauli terms corresponding to the 2-RDMs """ -import numpy as np from itertools import product -from grove.measurements.estimation import (remove_imaginary_terms, - estimate_pauli_sum, + +import numpy as np +from grove.measurements.estimation import (remove_imaginary_terms, estimate_pauli_sum, remove_identity) from grove.measurements.term_grouping import commuting_sets_by_zbasis -from pyquil.paulis import PauliTerm, PauliSum - from openfermion.transforms import jordan_wigner from openfermion.ops import FermionOperator -from forestopenfermion.rdm_utilities import (pauli_dict_relabel, - pauli_term_relabel) -from forestopenfermion.pyquil_connector import qubitop_to_pyquilpauli +from pyquil.paulis import PauliTerm, PauliSum + +from forest.openfermion.rdm_utilities import pauli_dict_relabel, pauli_term_relabel +from forest.openfermion.pyquil_connector import qubitop_to_pyquilpauli def _measure_list_of_pauli_terms(pauli_terms, variance_bound, program, diff --git a/forestopenfermion/rdm_utilities.py b/forest/openfermion/rdm_utilities.py similarity index 99% rename from forestopenfermion/rdm_utilities.py rename to forest/openfermion/rdm_utilities.py index 64e2e6b..b63618b 100644 --- a/forestopenfermion/rdm_utilities.py +++ b/forest/openfermion/rdm_utilities.py @@ -1,8 +1,9 @@ """ Utilities for RDMs """ -import numpy as np from itertools import product + +import numpy as np from pyquil.paulis import PauliTerm, PauliSum diff --git a/forestopenfermion/tests/__init__.py b/forest/openfermion/tests/__init__.py similarity index 100% rename from forestopenfermion/tests/__init__.py rename to forest/openfermion/tests/__init__.py diff --git a/forestopenfermion/tests/pyquil_connector_test.py b/forest/openfermion/tests/pyquil_connector_test.py similarity index 95% rename from forestopenfermion/tests/pyquil_connector_test.py rename to forest/openfermion/tests/pyquil_connector_test.py index 5855526..49d50f2 100644 --- a/forestopenfermion/tests/pyquil_connector_test.py +++ b/forest/openfermion/tests/pyquil_connector_test.py @@ -3,15 +3,15 @@ """ import pytest import numpy as np -from openfermion.ops import (FermionOperator, +from openfermion.ops import (FermionOperator, QubitOperator, InteractionOperator, InteractionRDM) from openfermion.utils import hermitian_conjugated from openfermion.transforms import jordan_wigner -from forestopenfermion.pyquil_connector import (pyquilpauli_to_qubitop, - qubitop_to_pyquilpauli) from pyquil.paulis import PauliTerm, PauliSum +from forest.openfermion.pyquil_connector import pyquilpauli_to_qubitop, qubitop_to_pyquilpauli + def test_confirm_interface(): """ diff --git a/forestopenfermion/tests/pyquil_generator_test.py b/forest/openfermion/tests/pyquil_generator_test.py similarity index 95% rename from forestopenfermion/tests/pyquil_generator_test.py rename to forest/openfermion/tests/pyquil_generator_test.py index cb0bc19..fb5744b 100644 --- a/forestopenfermion/tests/pyquil_generator_test.py +++ b/forest/openfermion/tests/pyquil_generator_test.py @@ -1,11 +1,12 @@ """Testing interface to pyqui.paulis""" -import numpy as np import pytest +import numpy as np from openfermion.ops import QubitOperator, FermionOperator -from forestopenfermion.pyquil_circuit_generator import exponentiate, TimeEvolution from pyquil.gates import H, RX, CNOT, RZ from pyquil.quil import Program +from forest.openfermion.pyquil_circuit_generator import exponentiate, TimeEvolution + def test_exponentiate(): one_pauli_term = QubitOperator('X0 Y2 Z3') diff --git a/forestopenfermion/tests/rdm_estimation_test.py b/forest/openfermion/tests/rdm_estimation_test.py similarity index 97% rename from forestopenfermion/tests/rdm_estimation_test.py rename to forest/openfermion/tests/rdm_estimation_test.py index 9466181..d43600d 100644 --- a/forestopenfermion/tests/rdm_estimation_test.py +++ b/forest/openfermion/tests/rdm_estimation_test.py @@ -2,8 +2,14 @@ Test RDM acquisition for accuracy """ import os + import numpy as np -from forestopenfermion.rdm_estimation import (pauli_terms_for_tpdm, +from openfermion.config import DATA_DIRECTORY +from openfermion.hamiltonians import MolecularData +from pyquil.paulis import term_with_coeff + +from forest.openfermion.pyquil_connector import pyquilpauli_to_qubitop +from forest.openfermion.rdm_estimation import (pauli_terms_for_tpdm, pauli_to_tpdm, pauli_terms_for_tpdm_aa, pauli_terms_for_tpdm_bb, @@ -11,13 +17,7 @@ pauli_to_tpdm_aa, pauli_to_tpdm_bb, pauli_to_tpdm_ab) - -from forestopenfermion.rdm_utilities import get_sz_spin_adapted - -from forestopenfermion.pyquil_connector import pyquilpauli_to_qubitop -from openfermion.config import DATA_DIRECTORY -from openfermion.hamiltonians import MolecularData -from pyquil.paulis import term_with_coeff +from forest.openfermion.rdm_utilities import get_sz_spin_adapted def test_h2_tpdm_build(): diff --git a/forestopenfermion/tests/rdm_utilities_test.py b/forest/openfermion/tests/rdm_utilities_test.py similarity index 93% rename from forestopenfermion/tests/rdm_utilities_test.py rename to forest/openfermion/tests/rdm_utilities_test.py index ac41cfd..4ddebfa 100644 --- a/forestopenfermion/tests/rdm_utilities_test.py +++ b/forest/openfermion/tests/rdm_utilities_test.py @@ -3,14 +3,14 @@ """ import os import numpy as np -from forestopenfermion.rdm_utilities import (get_sz_spin_adapted, unspin_adapt, - pauli_term_from_string, - pauli_dict_relabel, - pauli_term_relabel) from openfermion.config import DATA_DIRECTORY from openfermion.hamiltonians import MolecularData from pyquil.paulis import PauliTerm +from forest.openfermion.rdm_utilities import (get_sz_spin_adapted, pauli_dict_relabel, + pauli_term_from_string, pauli_term_relabel, + unspin_adapt) + def test_spin_adapt_h2(): """ diff --git a/forestopenfermion/version.py b/forest/openfermion/version.py similarity index 100% rename from forestopenfermion/version.py rename to forest/openfermion/version.py diff --git a/forestopenfermion/__init__.py b/forestopenfermion/__init__.py deleted file mode 100644 index 5b69c7a..0000000 --- a/forestopenfermion/__init__.py +++ /dev/null @@ -1,32 +0,0 @@ -# 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. - -from forestopenfermion.pyquil_circuit_generator import (exponentiate, - TimeEvolution) - -from forestopenfermion.pyquil_connector import (pyquilpauli_to_qubitop, - qubitop_to_pyquilpauli) - -from forestopenfermion.rdm_estimation import (pauli_terms_for_tpdm, - pauli_to_tpdm, - pauli_terms_for_tpdm_aa, - pauli_terms_for_tpdm_bb, - pauli_terms_for_tpdm_ab, - pauli_to_tpdm_aa, - pauli_to_tpdm_bb, - pauli_to_tpdm_ab) - -from forestopenfermion.rdm_utilities import (get_sz_spin_adapted, - unspin_adapt, - pauli_term_from_string, - pauli_term_relabel, - pauli_dict_relabel) diff --git a/requirements.txt b/requirements.txt index e8ac8ce..9396b16 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,3 @@ quantum-grove < 2.0.0 # for testing pytest - diff --git a/setup.py b/setup.py index 718b74f..c4ba29a 100755 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ from setuptools import setup if sys.version_info < (3, 6): - raise ImportError('The forestopenfermion library requires Python 3.6 or above.') + raise ImportError('The forest-openfermion library requires Python 3.6 or above.') with open('README.md', 'r') as f: long_description = f.read() @@ -28,15 +28,15 @@ __version__ = f.read().strip() # save the source code in version.py -with open('forestopenfermion/version.py', 'r') as f: +with open('forest/openfermion/version.py', 'r') as f: version_file_source = f.read() # overwrite version.py in the source distribution -with open('forestopenfermion/version.py', 'w') as f: +with open('forest/openfermion/version.py', 'w') as f: f.write(f'__version__ = \'{__version__}\'\n') setup( - name='forestopenfermion', + name='forest-openfermion', version=__version__, author='Rigetti Computing', author_email='software@rigetti.com', @@ -51,10 +51,10 @@ 'pyquil >= 2.0.0, < 3.0.0', 'quantum-grove < 2.0.0' ], - packages=['forestopenfermion'], + packages=['forest.openfermion'], python_requires='>=3.6' ) # restore version.py to its previous state -with open('forestopenfermion/version.py', 'w') as f: +with open('forest/openfermion/version.py', 'w') as f: f.write(version_file_source)