Skip to content

Commit

Permalink
Add basic test and CI
Browse files Browse the repository at this point in the history
  • Loading branch information
darnstrom committed Nov 8, 2024
1 parent f721648 commit fd65e12
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Basic CI

on:
workflow_dispatch:
pull_request:
branches:
- master
push:
branches:
- master
tags: "*"

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
strategy:
matrix:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Python interface
run: |
python -m pip install --upgrade pip
pip install numpy pytest
pip install .
- name: Run unit tests
run: python -m pytest test/
35 changes: 35 additions & 0 deletions .github/workflows/pip.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Test latest pip version

on:
workflow_dispatch:
pull_request:
branches:
- master
push:
branches:
- master
tags: "*"

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
strategy:
matrix:
python-version: ["3.10"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install Python interface from pip
run: |
python -m pip install --upgrade pip
pip install numpy pytest
pip install pdaqp
- name: Run unit tests
run: python -m pytest test/
30 changes: 30 additions & 0 deletions test/basic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
"""
Test pdaqp
"""
import unittest
import numpy
from pdaqp import MPQP

class Testing(unittest.TestCase):
"""Testing class for pdaqp."""

def test_python_demo(self):
H = numpy.array([[1.5064, 0.4838], [0.4838, 1.5258]])
f = numpy.zeros((2,1))
F = numpy.array([[9.6652, 5.2115], [7.0732, -7.0879]])
A = numpy.array([[1.0, 0], [-1, 0], [0, 1], [0, -1]])
b = 2*numpy.ones((4,1));
B = numpy.zeros((4,2));

thmin = -1.5*numpy.ones(2)
thmax = 1.5*numpy.ones(2)

# Setup mpQP and solve it
mpQP = MPQP(H,f,F,A,b,B,thmin,thmax)
mpQP.solve()

self.assertEqual(len(mpQP.CRs), 9)


if __name__ == '__main__':
unittest.main()

0 comments on commit fd65e12

Please sign in to comment.