Skip to content

Commit 2431e21

Browse files
committed
Switch to GHA and update the README
Signed-off-by: Vadim Markovtsev <[email protected]>
1 parent 17775d8 commit 2431e21

9 files changed

+138
-13
lines changed

.flake8

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[flake8]
2+
ignore=D100,D104,D301,W503,W504
3+
exclude=doc
4+
max-line-length=99
5+
inline-quotes="
6+
import-order-style=appnexus
7+
application-package-names=lapjv
8+
per-file-ignores=
9+
setup.py:D
10+
test.py*:D

.github/workflows/push.yml

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
name: Push
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
9+
env:
10+
PIP_CACHE: |
11+
~/.cache/pip
12+
~/.local/bin
13+
~/.local/lib/python3.*/site-packages
14+
15+
jobs:
16+
flake8:
17+
name: flake8
18+
if: "!contains(github.event.head_commit.message, 'Bump version')"
19+
runs-on: ubuntu-20.04
20+
steps:
21+
- name: actions/checkout
22+
uses: actions/checkout@v2
23+
- name: actions/cache
24+
uses: actions/cache@v2
25+
with:
26+
path: ${{ env.PIP_CACHE }}
27+
key: ubuntu-20.04-pip-lint-${{ hashFiles('lint-requirements.txt') }}
28+
restore-keys: ubuntu-20.04-pip-lint-
29+
- name: pip lint-requirements.txt
30+
run: |
31+
set -x
32+
pip3 install -r lint-requirements.txt --no-warn-script-location
33+
echo "$HOME/.local/bin" >> $GITHUB_PATH
34+
- name: flake8
35+
run: |
36+
set -x
37+
flake8
38+
test:
39+
name: Unit tests
40+
if: "!contains(github.event.head_commit.message, 'Bump version')"
41+
runs-on: ubuntu-20.04
42+
steps:
43+
- name: actions/checkout
44+
uses: actions/checkout@v2
45+
- name: actions/cache pip
46+
uses: actions/cache@v2
47+
with:
48+
path: ${{ env.PIP_CACHE }}
49+
key: ubuntu-20.04-pip-main-${{ hashFiles('requirements.txt', 'test-requirements.txt') }}
50+
restore-keys: ubuntu-20.04-pip-main-
51+
- name: pip requirements.txt
52+
run: |
53+
set -x
54+
pip3 install -r requirements.txt --no-warn-script-location
55+
pip3 install -r test-requirements.txt --no-warn-script-location
56+
pip3 install -e .
57+
echo "$HOME/.local/bin" >> $GITHUB_PATH
58+
- name: test
59+
run: |
60+
set -x
61+
python3 -m unittest discover .
62+
bump_version:
63+
name: Bump the version
64+
needs: [ flake8, test ]
65+
if: "!contains(github.event.head_commit.message, 'Bump version') && github.ref == 'refs/heads/master'"
66+
runs-on: ubuntu-20.04
67+
steps:
68+
- name: actions/checkout
69+
uses: actions/checkout@v2
70+
- name: current_version
71+
run: echo "current_version=$(grep 'version=' setup.py | cut -d\" -f2)" >> $GITHUB_ENV
72+
- name: FragileTech/bump-version
73+
uses: FragileTech/bump-version@main
74+
with:
75+
current_version: "${{ env.current_version }}"
76+
files: setup.py
77+
commit_name: Vadim Markovtsev
78+
commit_email: [email protected]
79+
login: vmarkovtsev
80+
token: "${{ secrets.BUMP_VERSION_TOKEN }}"

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
.idea
12
# Created by .ignore support plugin (hsz.mobi)
23
### Python template
34
# Byte-compiled / optimized / DLL files

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ from lapjv import lapjv
4747
row_ind, col_ind, _ = lapjv(cost_matrix)
4848
```
4949

50+
The assignment matrix by row is `row_ind`: the value at n-th place is the assigned column index to the n-th row.
51+
`col_ind` is the reverse of `row_ind`: mapping from columns to row indexes.
52+
53+
Note: a bijection is only possible for sets with equal cardinality. If you need to map A vectors to B vectors,
54+
derive the square symmetric (A+B) x (A+B) matrix: take the first A rows and columns from A and
55+
the remaining [A..A+B] rows and columns from B. Set the A->A and B->B costs to some maximum distance value,
56+
big enough so that you don't see assignment errors.
57+
5058
Illegal instruction
5159
-------------------
5260

@@ -56,6 +64,11 @@ This error appears if your CPU does not support the AVX2 instruction set. We do
5664
pip3 install git+https://github.com/src-d/lapjv
5765
```
5866

67+
NAN-s
68+
-----
69+
70+
NAN-s in the cost matrix lead to completely undefined result. It is the caller's responsibility to check them.
71+
5972
License
6073
-------
6174
MIT Licensed,see [LICENSE](LICENSE)

lint-requirements.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
flake8==3.8.4
2+
flake8-bugbear==20.11.1
3+
flake8-docstrings==1.5.0
4+
flake8-import-order==0.18.1
5+
flake8-quotes==3.2.0
6+
flake8-commas==2.0.0
7+
pydocstyle==5.1.1
8+
pycodestyle==2.6.0

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
numpy==1.19.5

setup.py

+19-10
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,46 @@
1+
from pathlib import Path
12
import platform
2-
from setuptools import setup, Extension
3+
34
import numpy
5+
from setuptools import Extension, setup
46

57
CXX_ARGS = {
68
"Darwin": ["-std=c++11", "-march=native", "-ftree-vectorize"],
79
"Linux": ["-fopenmp", "-std=c++11", "-march=native", "-ftree-vectorize"],
8-
"Windows": ["/openmp", "/std:c++latest", "/arch:AVX2"]
10+
"Windows": ["/openmp", "/std:c++latest", "/arch:AVX2"],
911
}
1012

13+
project_root = Path(__file__).parent
14+
15+
with open(project_root / "README.md", encoding="utf-8") as f:
16+
long_description = f.read()
17+
1118
setup(
1219
name="lapjv",
13-
description="Linear sum assignment problem solver using Jonker-Volgenant "
14-
"algorithm.",
20+
description="Linear sum assignment problem solver using Jonker-Volgenant algorithm.",
21+
long_description=long_description,
22+
long_description_content_type="text/markdown",
1523
version="1.3.1",
1624
license="MIT",
1725
author="Vadim Markovtsev",
18-
author_email="[email protected]",
26+
author_email="[email protected]",
1927
url="https://github.com/src-d/lapjv",
2028
download_url="https://github.com/src-d/lapjv",
2129
ext_modules=[Extension("lapjv",
2230
sources=["python.cc"],
2331
extra_compile_args=CXX_ARGS[platform.system()],
2432
include_dirs=[numpy.get_include()])],
25-
install_requires=["numpy"],
33+
install_requires=["numpy>=1.0.0"],
34+
tests_require=["scipy>=1.0.0"],
2635
classifiers=[
27-
"Development Status :: 4 - Beta",
36+
"Development Status :: 5 - Production/Stable",
2837
"Intended Audience :: Developers",
2938
"License :: OSI Approved :: MIT License",
3039
"Operating System :: POSIX :: Linux",
3140
"Topic :: Scientific/Engineering :: Information Analysis",
32-
"Programming Language :: Python :: 3.5",
33-
"Programming Language :: Python :: 3.6"
34-
]
41+
"Programming Language :: Python :: 3.8",
42+
"Programming Language :: Python :: 3.9",
43+
],
3544
)
3645

3746
# python3 setup.py bdist_wheel

test-requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
scipy==1.6.0

test.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import unittest
2-
from lapjv import lapjv
3-
from numpy import random, meshgrid, linspace, dstack, sqrt, array, \
4-
float32, float64
2+
3+
from numpy import array, dstack, float32, float64, linspace, meshgrid, random, sqrt
54
from scipy.spatial.distance import cdist
65

6+
from lapjv import lapjv
7+
78

89
class LapjvTests(unittest.TestCase):
910
def _test_random_100(self, dtype):
@@ -58,5 +59,6 @@ def test_1024(self):
5859
self.assertTrue((row_ind_lapjv32 == row_ind_lapjv64).all())
5960
self.assertTrue((col_ind_lapjv32 == col_ind_lapjv64).all())
6061

62+
6163
if __name__ == "__main__":
6264
unittest.main()

0 commit comments

Comments
 (0)