Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable tests on Windows #246

Merged
merged 1 commit into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/test_latest_versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ jobs:
include:
- os: macos-latest
python-version: "3.8"
- os: windows-latest
python-version: "3.10"
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -44,9 +46,13 @@ jobs:
run: |
pver=${{ matrix.python-version }}
tox -epy${pver/./} -- --run-slow
notebook_flags=""
if [ "$pver" = "3.11" ]; then
echo Skipping tutorials that require cplex
tox -epy${pver/./}-notebook -- --ignore=docs/circuit_cutting/cutqc/tutorials/tutorial_1_automatic_cut_finding.ipynb --ignore=docs/circuit_cutting/cutqc/tutorials/tutorial_3_cutting_with_quantum_serverless.ipynb
else
tox -epy${pver/./}-notebook
notebook_flags="${notebook_flags} --ignore=docs/circuit_cutting/cutqc/tutorials/tutorial_1_automatic_cut_finding.ipynb --ignore=docs/circuit_cutting/cutqc/tutorials/tutorial_3_cutting_with_quantum_serverless.ipynb"
fi
if [ "$RUNNER_OS" = "Windows" ]; then
echo Skipping tutorials \& how-tos that require pyscf
notebook_flags="${notebook_flags} --ignore=docs/entanglement_forging --ignore=docs/_build/jupyter_execute/entanglement_forging/how-tos"
fi
tox -epy${pver/./}-notebook -- ${notebook_flags}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div align="left">

[![Stability](https://img.shields.io/badge/Stability-alpha-f4d03f.svg)](https://github.com/Qiskit-Extensions/circuit-knitting-toolbox/releases)
![Platform](https://img.shields.io/badge/Platform-Linux%20%7C%20macOS-informational)
![Platform](https://img.shields.io/badge/Platform-Linux%20%7C%20macOS%20%7C%20Windows-informational)
[![Python](https://img.shields.io/badge/Python-3.8%20%7C%203.9%20%7C%203.10%20%7C%203.11-informational)](https://www.python.org/)
[![Qiskit](https://img.shields.io/badge/Qiskit-%E2%89%A5%200.43.0-6133BD)](https://github.com/Qiskit/qiskit)
[![Qiskit Nature](https://img.shields.io/badge/Qiskit%20Nature-%E2%89%A5%200.5.2-6133BD)](https://github.com/Qiskit/qiskit-nature)
Expand Down
4 changes: 4 additions & 0 deletions test/forging/test_entanglement_forging_ground_state_solver.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"""Tests for EntanglementForgingVQE module."""

import unittest
import importlib.util
import numpy as np

from qiskit.algorithms.optimizers import SPSA
Expand All @@ -28,12 +29,15 @@
EntanglementForgingGroundStateSolver,
)

pyscf_available = importlib.util.find_spec("pyscf") is not None


class TestEntanglementForgingGroundStateSolver(unittest.TestCase):
def setUp(self):
# Hard-code some ansatz params/lambdas
self.optimizer = SPSA(maxiter=0)

@unittest.skipIf(not pyscf_available, "pyscf is not installed")
def test_entanglement_forging_vqe_hydrogen(self):
"""Test of applying Entanglement Forged Solver to to compute the energy of a H2 molecule."""
# Set up the ElectronicStructureProblem
Expand Down
5 changes: 5 additions & 0 deletions test/forging/test_entanglement_forging_knitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"""Tests for EntanglementForgingKnitter module."""

import os
import importlib.util
import unittest
import pytest

Expand All @@ -30,6 +31,8 @@
convert_cholesky_operator,
)

pyscf_available = importlib.util.find_spec("pyscf") is not None


class TestEntanglementForgingKnitter(unittest.TestCase):
def setUp(self):
Expand Down Expand Up @@ -72,6 +75,7 @@ def create_mock_ansatz_circuit(self, num_qubits: int) -> QuantumCircuit:

return ansatz

@unittest.skipIf(not pyscf_available, "pyscf is not installed")
def test_entanglement_forging_H2(self):
"""
Test to apply Entanglement Forging to compute the energy of a H2 molecule,
Expand Down Expand Up @@ -108,6 +112,7 @@ def test_entanglement_forging_H2(self):
# Ensure ground state energy output is within tolerance
self.assertAlmostEqual(energy + energy_shift, -1.121936544469326)

@unittest.skipIf(not pyscf_available, "pyscf is not installed")
def test_entanglement_forging_H2O(self): # pylint: disable=too-many-locals
"""
Test to apply Entanglement Forging to compute the energy of a H2O molecule,
Expand Down