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

GitHub Actions running PyTest #190

Merged
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
38 changes: 38 additions & 0 deletions .github/workflows/functional_tests.yaml
Original file line number Diff line number Diff line change
@@ -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"]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: testing Python 3.7-3.11. According to our readme, we support 3.7-3.9. Python 3.7 end of life was June 27th, 2023. We can modify this as needed though; feel free to recommend more/less python versions!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in that case we can modify the support to 3.8-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"
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion test/hadamard_grad/test_hadamard_grad.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -36,4 +38,4 @@ def test_hadamard_grad():

if __name__ == "__main__":

test_hadamard_grad()
test_hadamard_grad()
3 changes: 2 additions & 1 deletion test/plugin/test_qiskit_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
from torchquantum.util import switch_little_big_endian_state

import torch
import pytest

pauli_str_op_dict = {
"X": X,
Expand All @@ -41,7 +42,7 @@
"I": I,
}


@pytest.mark.skip
def test_expval_observable():
# seed = 0
# random.seed(seed)
Expand Down
5 changes: 2 additions & 3 deletions torchquantum/density/density_func.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading