From 5683a77db67a38db615fba06ad89eeeace229ec2 Mon Sep 17 00:00:00 2001 From: Peter Karalekas Date: Tue, 28 May 2019 15:32:35 -0700 Subject: [PATCH 1/9] Remove .coveragerc file as we're not testing coverage anymore --- .coveragerc | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 .coveragerc 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 From 023b031bd8e425127829132bd0e0afa0cb63678a Mon Sep 17 00:00:00 2001 From: Peter Karalekas Date: Tue, 28 May 2019 15:33:09 -0700 Subject: [PATCH 2/9] Add GitLab CI YAML file for an additional CI pipeline --- .gitlab-ci.yml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .gitlab-ci.yml 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 From 8f886a48006166b663309b6939e3958e54fc8144 Mon Sep 17 00:00:00 2001 From: Peter Karalekas Date: Tue, 28 May 2019 15:56:37 -0700 Subject: [PATCH 3/9] Rename PyPI package to forest-openfermion --- README.md | 4 ++-- setup.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 25f65f2..066c505 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ The Rigetti Forest Plugin for OpenFermion ========================================= -[![Build Status](https://semaphoreci.com/api/v1/rigetti/forestopenfermion/branches/master/shields_badge.svg)](https://semaphoreci.com/rigetti/forestopenfermion) +[![Build Status](https://semaphoreci.com/api/v1/rigetti/forest-openfermion/branches/master/shields_badge.svg)](https://semaphoreci.com/rigetti/forest-openfermion) [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 @@ -20,7 +20,7 @@ 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 diff --git a/setup.py b/setup.py index 0af2d04..64bce7c 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() @@ -36,7 +36,7 @@ f.write(f'__version__ = \'{__version__}\'\n') setup( - name='forestopenfermion', + name='forest-openfermion', version=__version__, author='Rigetti Computing', author_email='software@rigetti.com', From b3a29899f0813b5652b928d74ac475bd6b983713 Mon Sep 17 00:00:00 2001 From: Peter Karalekas Date: Tue, 28 May 2019 16:02:04 -0700 Subject: [PATCH 4/9] Add note about the archiving of the repository --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 066c505..9077553 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,16 @@ 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). + [![Build Status](https://semaphoreci.com/api/v1/rigetti/forest-openfermion/branches/master/shields_badge.svg)](https://semaphoreci.com/rigetti/forest-openfermion) -[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 +construction and simulation environment [Forest](http://www.rigetti.com/forest) to interface with OpenFermion. Getting Started @@ -26,8 +31,7 @@ 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 From ce845d30db814ed612ec8b83288cb209915988bd Mon Sep 17 00:00:00 2001 From: Peter Karalekas Date: Tue, 28 May 2019 17:13:59 -0700 Subject: [PATCH 5/9] Change the module structure from forestopenfermion to forest.openfermion --- forest/openfermion/__init__.py | 30 +++++++++++++++++ .../openfermion}/pyquil_circuit_generator.py | 4 +-- .../openfermion}/pyquil_connector.py | 0 .../openfermion}/rdm_estimation.py | 15 ++++----- .../openfermion}/rdm_utilities.py | 3 +- .../openfermion}/tests/__init__.py | 0 .../tests/pyquil_connector_test.py | 6 ++-- .../tests/pyquil_generator_test.py | 5 +-- .../openfermion}/tests/rdm_estimation_test.py | 16 +++++----- .../openfermion}/tests/rdm_utilities_test.py | 8 ++--- .../openfermion}/version.py | 0 forestopenfermion/__init__.py | 32 ------------------- setup.py | 8 ++--- 13 files changed, 63 insertions(+), 64 deletions(-) create mode 100644 forest/openfermion/__init__.py rename {forestopenfermion => forest/openfermion}/pyquil_circuit_generator.py (97%) rename {forestopenfermion => forest/openfermion}/pyquil_connector.py (100%) rename {forestopenfermion => forest/openfermion}/rdm_estimation.py (98%) rename {forestopenfermion => forest/openfermion}/rdm_utilities.py (99%) rename {forestopenfermion => forest/openfermion}/tests/__init__.py (100%) rename {forestopenfermion => forest/openfermion}/tests/pyquil_connector_test.py (95%) rename {forestopenfermion => forest/openfermion}/tests/pyquil_generator_test.py (95%) rename {forestopenfermion => forest/openfermion}/tests/rdm_estimation_test.py (97%) rename {forestopenfermion => forest/openfermion}/tests/rdm_utilities_test.py (93%) rename {forestopenfermion => forest/openfermion}/version.py (100%) delete mode 100644 forestopenfermion/__init__.py 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/setup.py b/setup.py index 64bce7c..192a32c 100755 --- a/setup.py +++ b/setup.py @@ -28,11 +28,11 @@ __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( @@ -51,10 +51,10 @@ 'pyquil < 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) From efb40a144533bbbe0e7beffabe31ed1cefaa6994 Mon Sep 17 00:00:00 2001 From: Peter Karalekas Date: Tue, 28 May 2019 17:14:29 -0700 Subject: [PATCH 6/9] Add pkgutil-style namespace package __init__.py to forest dir --- forest/__init__.py | 1 + 1 file changed, 1 insertion(+) create mode 100644 forest/__init__.py 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__) From e463acad45820cf53e303e078acf41541cb478db Mon Sep 17 00:00:00 2001 From: Peter Karalekas Date: Tue, 28 May 2019 17:18:21 -0700 Subject: [PATCH 7/9] Suggestively pin all reqs in requirements.txt because we're archiving --- requirements.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/requirements.txt b/requirements.txt index a1799d0..2361e71 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,8 +1,8 @@ -scipy < 1.0.0 -numpy < 2.0.0 -openfermion < 1.0.0 -pyquil < 3.0.0 -quantum-grove < 2.0.0 +scipy == 0.19.1 +numpy == 1.16.4 +openfermion == 0.9.0 +pyquil == 2.8.0 +quantum-grove == 1.7.0 # for testing pytest From 5711fe66f0e9bab2ce97ea8bdab7f9b901c3c6da Mon Sep 17 00:00:00 2001 From: Peter Karalekas Date: Tue, 28 May 2019 17:19:24 -0700 Subject: [PATCH 8/9] Include NOTICE in MANIFEST.in --- MANIFEST.in | 1 + requirements.txt | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) 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/requirements.txt b/requirements.txt index 2361e71..ca36df4 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,4 +6,3 @@ quantum-grove == 1.7.0 # for testing pytest - From 63954f97003393c2cf1963beaf7e1af36b488963 Mon Sep 17 00:00:00 2001 From: Peter Karalekas Date: Tue, 28 May 2019 17:21:19 -0700 Subject: [PATCH 9/9] Add GitLab CI badge to the README --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 9077553..4392cb6 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ decided to archive it. It should work in its current state, but if you find issu 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](https://semaphoreci.com/api/v1/rigetti/forest-openfermion/branches/master/shields_badge.svg)](https://semaphoreci.com/rigetti/forest-openfermion) [OpenFermion](http://openfermion.org) is an open-source package for compiling and analyzing