Skip to content
Open
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
33 changes: 33 additions & 0 deletions .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion example/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Template for a Python Package."""

from ._example import *
from .submodule import *
from .submodule import *
16 changes: 8 additions & 8 deletions example/submodule.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
return numpy.array(vec1[0]*vec2[1]-vec1[1]*vec2[0])