Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8fcd57c

Browse files
authored
Merge pull request #173 from Geosyntec/more-gh-actions-1
Create python-package.yml
2 parents 165f93b + 2d63160 commit 8fcd57c

15 files changed

Lines changed: 107 additions & 68 deletions
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2+
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Python package
5+
6+
on:
7+
push:
8+
branches: [ master ]
9+
pull_request:
10+
branches: [ master ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
strategy:
17+
matrix:
18+
python-version: [3.6, 3.7, 3.8]
19+
20+
steps:
21+
- uses: actions/checkout@v2
22+
- name: Set up Python ${{ matrix.python-version }}
23+
uses: actions/setup-python@v2
24+
with:
25+
python-version: ${{ matrix.python-version }}
26+
- name: Install dependencies
27+
run: |
28+
python -m pip install --upgrade pip
29+
pip install flake8 pytest
30+
if [ -f requirements_dev.txt ]; then pip install -r requirements_dev.txt; fi
31+
- name: Lint with flake8
32+
run: |
33+
# stop the build if there are Python syntax errors or undefined names
34+
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics --exclude .git,docs/*
35+
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
36+
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
37+
- name: Test with pytest
38+
run: |
39+
python check_wqio.py --doctest-modules

‎.travis.yml‎

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
11
language: python
22

33
matrix:
4-
include:
4+
fast_finish: true
5+
include:
56
- python: 3.8
6-
language: python
7-
sudo: required
8-
dist: xenial
9-
env:
10-
- COVERAGE=true
11-
- ARGS="--strict"
12-
- python: 3.7
13-
language: python
14-
sudo: required
15-
dist: xenial
16-
env:
17-
- COVERAGE=false
18-
- ARGS=""
19-
- python: 3.6
20-
env:
21-
- COVERAGE=false
22-
- ARGS=""
237

248
before_install:
259
- wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
@@ -37,10 +21,8 @@ install:
3721
- conda list
3822

3923
script:
40-
- coverage run --source wqio check_wqio.py --verbose ${ARGS}
24+
- coverage run --source wqio check_wqio.py --strict --verbose
4125

4226
after_success:
43-
- if [ ${COVERAGE} = true ]; then
44-
coverage report -m;
45-
codecov;
46-
fi
27+
- coverage report -m;
28+
- codecov;

‎requirements.txt‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
numpy
2+
scipy
3+
pandas
4+
matplotlib
5+
statsmodels
6+
seaborn
7+
probscale

‎requirements_dev.txt‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
numpy
2+
scipy
3+
pandas
4+
matplotlib
5+
statsmodels
6+
seaborn
7+
probscale
8+
pytest
9+
pytest-cov
10+
pytest-mpl
11+
pytest-pep8
12+
coverage
13+
docopt
14+
requests
15+
pyyaml

‎wqio/ros.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def _detection_limit_index(res, cohn):
230230
"""
231231

232232
if cohn.shape[0] > 0:
233-
index, = numpy.where(cohn["lower_dl"] <= res)
233+
(index,) = numpy.where(cohn["lower_dl"] <= res)
234234
det_limit_index = index[-1]
235235
else:
236236
det_limit_index = 0
-2.21 KB
Loading
-1.98 KB
Loading

‎wqio/tests/test_datacollections.py‎

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
from unittest import mock
1111
import pytest
12-
import pandas.util.testing as pdtest
12+
import pandas.testing as pdtest
1313
from wqio.tests import helpers
1414

1515
from wqio.features import Location, Dataset
@@ -33,7 +33,7 @@ def check_stat(expected_csv, result, comp=False):
3333
pdtest.assert_frame_equal(
3434
expected.sort_index(axis="columns"),
3535
result.sort_index(axis="columns").round(6),
36-
check_less_precise=True,
36+
atol=1e-5,
3737
)
3838

3939

@@ -308,7 +308,7 @@ def test_geostd_dev(dc):
308308
def test_shapiro(dc):
309309
known_csv = """\
310310
station,Inflow,Inflow,Outflow,Outflow,Reference,Reference
311-
result,pvalue,shapiro,pvalue,shapiro,pvalue,shapiro
311+
result,pvalue,statistic,pvalue,statistic,pvalue,statistic
312312
param,,,,,,
313313
A,1.8e-05,0.685783,1e-06,0.576069,4e-06,0.61735
314314
B,1e-06,0.594411,0.0,0.530962,0.0,0.41471
@@ -324,7 +324,7 @@ def test_shapiro(dc):
324324
def test_shapiro_log(dc):
325325
known_csv = """\
326326
station,Inflow,Inflow,Outflow,Outflow,Reference,Reference
327-
result,log-shapiro,pvalue,log-shapiro,pvalue,log-shapiro,pvalue
327+
result,statistic,pvalue,statistic,pvalue,statistic,pvalue
328328
param,,,,,,
329329
A,0.983521938,0.96662426,0.979861856,0.913820148,0.939460814,0.234214202
330330
B,0.957531095,0.390856266,0.97048676,0.722278714,0.967978418,0.735424638
@@ -467,27 +467,27 @@ def test_levene(dc):
467467
@helpers.seed
468468
def test_wilcoxon(dc):
469469
known_csv = """\
470-
,,pvalue,pvalue,pvalue,wilcoxon,wilcoxon,wilcoxon
470+
,,wilcoxon,wilcoxon,wilcoxon,pvalue,pvalue,pvalue
471471
loc_2,,Inflow,Outflow,Reference,Inflow,Outflow,Reference
472472
param,loc_1,,,,,,
473-
A,Inflow,,0.0351569731,0.4074344561,,32.0,59.0
474-
A,Outflow,0.0351569731,,0.2552905052,32.0,,46.0
475-
A,Reference,0.4074344561,0.2552905052,,59.0,46.0,
476-
B,Inflow,,0.6001794871,0.1823383542,,38.0,22.0
477-
B,Outflow,0.6001794871,,0.8588630128,38.0,,31.0
478-
B,Reference,0.1823383542,0.8588630128,,22.0,31.0,
479-
C,Inflow,,0.1592244176,0.5840564537,,75.0,120.0
480-
C,Outflow,0.1592244176,,0.4470311612,75.0,,113.0
481-
C,Reference,0.5840564537,0.4470311612,,120.0,113.0,
482-
D,Inflow,,0.5936182408,0.5302845968,,44.0,31.0
483-
D,Outflow,0.5936182408,,0.9721253297,44.0,,45.0
484-
D,Reference,0.5302845968,0.9721253297,,31.0,45.0,
485-
E,Inflow,,0.8589549227,0.3862707204,,21.0,19.0
486-
E,Outflow,0.8589549227,,0.0711892343,21.0,,16.0
487-
E,Reference,0.3862707204,0.0711892343,,19.0,16.0,
488-
F,Inflow,,0.4924592975,0.952765022,,62.0,22.0
489-
F,Outflow,0.4924592975,,0.6566419343,62.0,,28.0
490-
F,Reference,0.952765022,0.6566419343,,22.0,28.0
473+
A,Inflow,,32.0,59.0,,0.03479,0.430679
474+
A,Outflow,32.0,,46.0,0.03479,,0.274445
475+
A,Reference,59.0,46.0,,0.430679,0.274445,
476+
B,Inflow,,38.0,22.0,,0.600179,0.182338
477+
B,Outflow,38.0,,31.0,0.600179,,0.858863
478+
B,Reference,22.0,31.0,,0.182338,0.858863,
479+
C,Inflow,,75.0,120.0,,0.167807,0.601046
480+
C,Outflow,75.0,,113.0,0.167807,,0.463381
481+
C,Reference,120.0,113.0,,0.601046,0.463381,
482+
D,Inflow,,44.0,31.0,,0.593618,0.530285
483+
D,Outflow,44.0,,45.0,0.593618,,0.972125
484+
D,Reference,31.0,45.0,,0.530285,0.972125,
485+
E,Inflow,,21.0,19.0,,0.910156,0.386271
486+
E,Outflow,21.0,,16.0,0.910156,,0.077148
487+
E,Reference,19.0,16.0,,0.386271,0.077148,
488+
F,Inflow,,62.0,22.0,,0.492459,0.952765
489+
F,Outflow,62.0,,28.0,0.492459,,0.656642
490+
F,Reference,22.0,28.0,,0.952765,0.656642,
491491
"""
492492
with pytest.warns(UserWarning):
493493
check_stat(known_csv, dc.wilcoxon, comp=True)
@@ -611,9 +611,7 @@ def test_inventory(dc):
611611
)
612612
)
613613
expected = pandas.read_csv(known_csv, index_col=[0, 1]).astype(int)
614-
pdtest.assert_frame_equal(
615-
expected, dc.inventory.astype(int), check_names=False, check_less_precise=True
616-
)
614+
pdtest.assert_frame_equal(expected, dc.inventory.astype(int), check_names=False)
617615

618616

619617
def test_inventory_noNDs(dc_noNDs):
@@ -644,10 +642,7 @@ def test_inventory_noNDs(dc_noNDs):
644642
)
645643
expected = pandas.read_csv(known_csv, index_col=[0, 1]).astype(int)
646644
pdtest.assert_frame_equal(
647-
expected,
648-
dc_noNDs.inventory.astype(int),
649-
check_names=False,
650-
check_less_precise=True,
645+
expected, dc_noNDs.inventory.astype(int), check_names=False,
651646
)
652647

653648

@@ -696,11 +691,11 @@ def test_stat_summary(dc):
696691

697692
expected = pandas.read_csv(known_csv, index_col=[0, 1]).T
698693
pdtest.assert_frame_equal(
699-
expected,
700-
dc.stat_summary(),
694+
expected.round(5),
695+
dc.stat_summary().round(5),
701696
check_names=False,
702-
check_less_precise=True,
703697
check_dtype=False,
698+
rtol=1e-4,
704699
)
705700

706701

‎wqio/tests/test_datasets.py‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33
import shutil
44

55
import pytest
6-
from pandas.util.testing import network
76

87
from wqio import datasets
98

109

11-
@network(url="https://github.com/Geosyntec/water-quality-dataset")
1210
@pytest.mark.parametrize("fname", ["bmpdata", "nsqd"])
1311
def test_download(fname):
1412
with tempfile.TemporaryDirectory() as tmpdir:

‎wqio/tests/test_features.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import pytest
66
import numpy.testing as nptest
7-
import pandas.util.testing as pdtest
7+
import pandas.testing as pdtest
88
from wqio.tests import helpers
99

1010
import numpy

0 commit comments

Comments
 (0)