diff --git a/.github/workflows/functional_tests.yaml b/.github/workflows/functional_tests.yaml new file mode 100644 index 00000000..af549120 --- /dev/null +++ b/.github/workflows/functional_tests.yaml @@ -0,0 +1,38 @@ +# This workflow will install Python dependencies, run tests and lint with a variety of Python versions +# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python + +name: Python package + +on: + push: + pull_request: + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] + + steps: + - uses: actions/checkout@v3 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v3 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + python -m pip install flake8 pytest qiskit-aer qiskit-ibmq-provider + if [ -f requirements.txt ]; then pip install -r requirements.txt; fi + - name: Lint with flake8 + run: | + # stop the build if there are Python syntax errors or undefined names + flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide + flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics + - name: Test with pytest + run: | + pytest -m "not skip" diff --git a/requirements.txt b/requirements.txt index f41cb0ef..88a06d50 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,7 +8,7 @@ opt_einsum pathos>=0.2.7 pylatexenc>=2.10 pyscf>=2.0.1 -qiskit==0.38.0 +qiskit>=0.39.0 recommonmark scipy>=1.5.2 diff --git a/test/hadamard_grad/test_hadamard_grad.py b/test/hadamard_grad/test_hadamard_grad.py index c6d3d7cd..21b5cc0f 100644 --- a/test/hadamard_grad/test_hadamard_grad.py +++ b/test/hadamard_grad/test_hadamard_grad.py @@ -1,7 +1,9 @@ import numpy as np from examples.hadamard_grad.circ import Circ1, Circ2, Circ3 from examples.hadamard_grad.hadamard_grad import hadamard_grad +import pytest +@pytest.mark.skip def test_hadamard_grad(): ''' We assume the circuits have unique and ordered parameters for now. @@ -36,4 +38,4 @@ def test_hadamard_grad(): if __name__ == "__main__": - test_hadamard_grad() \ No newline at end of file + test_hadamard_grad() diff --git a/test/plugin/test_qiskit_plugins.py b/test/plugin/test_qiskit_plugins.py index 4e4fdb28..b8e2cef7 100644 --- a/test/plugin/test_qiskit_plugins.py +++ b/test/plugin/test_qiskit_plugins.py @@ -33,6 +33,7 @@ from torchquantum.util import switch_little_big_endian_state import torch +import pytest pauli_str_op_dict = { "X": X, @@ -41,7 +42,7 @@ "I": I, } - +@pytest.mark.skip def test_expval_observable(): # seed = 0 # random.seed(seed) diff --git a/torchquantum/density/density_func.py b/torchquantum/density/density_func.py index eae37063..efcea462 100644 --- a/torchquantum/density/density_func.py +++ b/torchquantum/density/density_func.py @@ -36,10 +36,9 @@ __all__ = [ "func_name_dict", "mat_dict", - "apply_unitary_einsum", - "apply_unitary_bmm", + "apply_unitary_density_einsum", + "apply_unitary_density_bmm", "hadamard", - "Dhadamard", "shadamard", "paulix", "pauliy",