diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml new file mode 100644 index 0000000..3af6c93 --- /dev/null +++ b/.github/workflows/pythonpackage.yml @@ -0,0 +1,33 @@ +name: Python package + +on: [push] + +jobs: + build: + + runs-on: ubuntu-latest + strategy: + max-parallel: 4 + matrix: + python-version: [3.6, 3.7] + + steps: + - uses: actions/checkout@v1 + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v1 + with: + python-version: ${{ matrix.python-version }} + - name: Install dependencies + run: | + python -m pip install --upgrade pip + pip install -r requirements.txt + python setup.py build_ext --inplace + - name: Lint with pylint + run: | + pip install pylint + # stop the build if there are Python syntax errors or undefined names + pylint example + - name: Test with pytest + run: | + pip install pytest + pytest diff --git a/example/__init__.py b/example/__init__.py index 4448d42..90e5e7a 100644 --- a/example/__init__.py +++ b/example/__init__.py @@ -1,4 +1,4 @@ """Template for a Python Package.""" from ._example import * -from .submodule import * \ No newline at end of file +from .submodule import * diff --git a/example/submodule.py b/example/submodule.py index d3c0493..1eab4ed 100644 --- a/example/submodule.py +++ b/example/submodule.py @@ -2,19 +2,19 @@ from typing import TypeVar, Iterable, Tuple -T = TypeVar('T', int, float, complex) -Vector = Iterable[Tuple[T, T]] - import numpy +TNum = TypeVar('T', int, float, complex) +Vector = Iterable[Tuple[TNum, TNum]] + __all__ = ['cross_2d'] -def cross_2d(a: Vector, b: Vector): +def cross_2d(vec1: Vector, vec2: Vector): """Return the z coordinate of a cross product for 2D vectors. - + >>> cross_2d((1, 0), (1, 0)) - 0 + array(0) >>> cross_2d((1, 0), (0, 1)) - 1 + array(1) """ - return a[0]*b[1]-a[1]*b[0] \ No newline at end of file + return numpy.array(vec1[0]*vec2[1]-vec1[1]*vec2[0])