Skip to content
Draft
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
63 changes: 63 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# -----------------------
#
# Run a full build-and-test from the git repo
# using a combination of conda and pip to install
# all optional dependencies.
#
# This is the 'full' test suite.
#
# -----------------------

name: Build and test

on:
push:
branches:
- main
- master
pull_request:
branches:
- main
- master

jobs:
build-and-test:
name: Python ${{ matrix.python-version }}

strategy:
fail-fast: false
matrix:
python-version:
- 3.7
- 3.8
- 3.9
runs-on: ubuntu-latest

steps:
- name: Get source code
uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '${{ matrix.python-version }}'

- name: Install the software
run: python -m pip install Code/

- name: Package list
run: python -m pip list installed

- name: Run test suite
run: python -m pytest -ra --color yes --cov PyROQ --pyargs PyROQ --cov-report=xml --junitxml=pytest.xml

- name: Coverage report
run: python -m coverage report --show-missing

- name: Publish coverage to Codecov
uses: codecov/codecov-action@v1.2.1
with:
files: coverage.xml
flags: ${{ runner.os }},python${{ matrix.python-version }}
7 changes: 7 additions & 0 deletions Code/PyROQ/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2021 Cardiff University

"""Test suite for PyROQ
"""

__author__ = "Duncan Macleod <macleoddm@cardiff.ac.uk>"
33 changes: 33 additions & 0 deletions Code/PyROQ/tests/test_pyroq.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2021 Cardiff University

"""Test suite for `PyROQ.pyroq` module
"""

__author__ = "Duncan Macleod <macleoddm@cardiff.ac.uk>"

import numpy
import numpy.testing

import pytest

from .. import pyroq


@pytest.mark.parametrize(("a", "b", "result"), (
(numpy.array((1, 0, 0)), # a
numpy.array((0, 1, 0)), # b
numpy.array((0, 0, 0)), # result
),
(numpy.array((1, 1, 0)),
numpy.array((0, 1, 0)),
numpy.array((0.5, 0.5, 0)),
),
))
def test_proj(a, b, result):
"""Test `PyROQ.pyroq.proj` function over a few different cases
"""
numpy.testing.assert_array_equal(
pyroq.proj(a, b),
result,
)