Repository: google/qhbm-library (language: python)

Issue:
Add CI



Discussion / hints:

Fix patch:
diff --git a/.flake8 b/.flake8
index c5c6294e..8dd399ab 100644
--- a/.flake8
+++ b/.flake8
@@ -1,4 +1,3 @@
 [flake8]
 max-line-length = 88
 extend-ignore = E203
-
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 4859c169..b2b82da0 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -3,20 +3,30 @@ name: Continuous Integration
 on: [ pull_request ]
 
 jobs:
-  format:
-    name: Format check
+  lint-and-format:
+    name: Check for Lint and Format
     runs-on: ubuntu-16.04
-    timeout-minutes: 2
+    timeout-minutes: 5
     steps:
       - uses: actions/checkout@v2
       - uses: actions/setup-python@v2
-      - uses: psf/black@2f52e4b4929370ec503ee272bcc10d3176db8e89
+        with:
+          python-version: '3.8'
+          architecture: 'x64'
+      - name: Check code format
+        uses: psf/black@2f52e4b4929370ec503ee272bcc10d3176db8e89
         with:
           args: ". --diff"
+      - name: Lint check
+        run: |
+          python -m pip install --upgrade pip
+          pip install flake8==3.9.2
+          flake8 .
   test:
-    name: Lint check
+    name: Test
     runs-on: ubuntu-16.04
     timeout-minutes: 5
+    needs: [lint-and-format]
     steps:
       - uses: actions/checkout@v2
       - uses: actions/setup-python@v2
@@ -26,7 +36,8 @@ jobs:
       - name: Install dependencies
         run: |
           python -m pip install --upgrade pip
-          pip install flake8==3.9.2
-      - name: Lint with flake8
+          pip install --user poetry
+          poetry install
+      - name: Run tests
         run: |
-          flake8 .
+          poetry run pytest .
diff --git a/docs/install.md b/docs/install.md
new file mode 100644
index 00000000..f08e9a0a
--- /dev/null
+++ b/docs/install.md
@@ -0,0 +1,19 @@
+# Install the QHBM Library
+
+There are three ways to start developing with the QHBM Library:
+* Choose any example notebook at TODO, make a copy, and modify to suit your needs.
+* Install the package in a local environment.
+* Work from the source code.
+
+## Pip package
+
+### Requirements
+
+## Build from source
+
+The following steps are tested for Ubuntu-like systems.
+
+### 1. Set up a Python 3 development environment
+
+
+### 2. Create a virtual environment
diff --git a/poetry.lock b/poetry.lock
index 8b8e0dd2..f6816245 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -914,7 +914,7 @@ python-versions = "*"
 [metadata]
 lock-version = "1.1"
 python-versions = "~3.8"
-content-hash = "6c959625fa83ebb5ffd83904e3f40781d6b8f55409cb6c47d2f845790fc290c0"
+content-hash = "ae8832b1b7e834782ae07696bcd2778c328954817a80970508f24169abb2e3e5"
 
 [metadata.files]
 absl-py = [
diff --git a/pyproject.toml b/pyproject.toml
index 76923339..b3f59d62 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -16,10 +16,11 @@ tensorflow = "2.3.1"
 tensorflow-probability = "0.11.0"
 
 [tool.poetry.dev-dependencies]
-coverage = {extras = ["toml"], version = "~5.5"}
-pytest-cov = "~2.11.1"
+coverage = {extras = ["toml"], version = "5.5"}
+pytest-cov = "2.11.1"
 black = "21.5b1"
 flake8 = "3.9.2"
+pytest = "6.2.4"
 
 [tool.coverage.paths]
 source = ["qhbm_libary"]
diff --git a/scripts/prepare_pr.sh b/scripts/prepare_pr.sh
index a14668c4..97715c3f 100755
--- a/scripts/prepare_pr.sh
+++ b/scripts/prepare_pr.sh
@@ -13,5 +13,15 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 # ==============================================================================
+
 poetry run black qhbm_library/ tests/
 poetry run flake8
+retval=$?
+if [ "$retval" == 0 ]
+then
+  echo "Success: no lint found."
+else
+  echo "Please remove lint and try again."
+  exit 1
+fi
+poetry run pytest --cov .


Test patch:
diff --git a/tests/vqt_test.py b/tests/vqt_test.py
index 959c2072..13cf74fb 100644
--- a/tests/vqt_test.py
+++ b/tests/vqt_test.py
@@ -52,11 +52,11 @@ def test_loss_consistency(self):
             self.name,
         )
         num_samples = tf.constant(int(5e6))
-        num_random_hamiltonians = 4
-        for _ in range(num_random_hamiltonians):
-            cirq_ham = test_util.get_random_pauli_sum(self.raw_qubits)
-            tf_ham = tfq.convert_to_tensor([[cirq_ham]])
-            for beta in tf.constant([0.1, 0.2, 0.4, 0.8, 1.6, 3.2, 6.4]):
+        num_random_hamiltonians = 2
+        for beta in tf.constant([0.1, 0.4, 1.6, 6.4]):
+            for _ in range(num_random_hamiltonians):
+                cirq_ham = test_util.get_random_pauli_sum(self.raw_qubits)
+                tf_ham = tfq.convert_to_tensor([[cirq_ham]])
                 loss_estimate = vqt.vqt_loss(test_qhbm, num_samples, beta, tf_ham)
                 loss_exact = vqt.exact_vqt_loss(test_qhbm, num_samples, beta, tf_ham)
                 self.assertAllClose(loss_estimate, loss_exact, rtol=1e-2)