From 3a78e4e3839022a40c33baca17e0341e959d2b3c Mon Sep 17 00:00:00 2001 From: James Percival Date: Fri, 15 Nov 2019 13:57:56 +0000 Subject: [PATCH 1/4] Create pythonpackage.yml --- .github/workflows/pythonpackage.yml | 32 +++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/pythonpackage.yml diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml new file mode 100644 index 0000000..49acbe8 --- /dev/null +++ b/.github/workflows/pythonpackage.yml @@ -0,0 +1,32 @@ +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 + - name: Lint with pylint + run: | + pip install pylint + # stop the build if there are Python syntax errors or undefined names + pylint + - name: Test with pytest + run: | + pip install pytest + pytest From a54339faa1edd4b09e5e8aa59aa8ce91ff254f8a Mon Sep 17 00:00:00 2001 From: James Percival Date: Fri, 15 Nov 2019 14:02:05 +0000 Subject: [PATCH 2/4] Update pythonpackage.yml --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 49acbe8..6d739e4 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -25,7 +25,7 @@ jobs: run: | pip install pylint # stop the build if there are Python syntax errors or undefined names - pylint + pylint examples/*.py - name: Test with pytest run: | pip install pytest From c2f40a1973e9b84b9982cb7e46041c6aecc34ee7 Mon Sep 17 00:00:00 2001 From: James Percival Date: Fri, 15 Nov 2019 14:05:06 +0000 Subject: [PATCH 3/4] Update pythonpackage.yml --- .github/workflows/pythonpackage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 6d739e4..1fd7351 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -25,7 +25,7 @@ jobs: run: | pip install pylint # stop the build if there are Python syntax errors or undefined names - pylint examples/*.py + pylint example - name: Test with pytest run: | pip install pytest From c5097162f12b0c323cdaff8549201408bac6b844 Mon Sep 17 00:00:00 2001 From: James Percival Date: Fri, 15 Nov 2019 14:14:43 +0000 Subject: [PATCH 4/4] Fix pylint. --- .github/workflows/pythonpackage.yml | 1 + example/__init__.py | 2 +- example/submodule.py | 16 ++++++++-------- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.github/workflows/pythonpackage.yml b/.github/workflows/pythonpackage.yml index 1fd7351..3af6c93 100644 --- a/.github/workflows/pythonpackage.yml +++ b/.github/workflows/pythonpackage.yml @@ -21,6 +21,7 @@ jobs: 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 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])