Skip to content

Commit

Permalink
Merge pull request #68 from UDST/update-travis
Browse files Browse the repository at this point in the history
Update Travis script
  • Loading branch information
smmaurer committed Nov 16, 2020
2 parents f8dbfc4 + 35e8b79 commit b7de06e
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 31 deletions.
39 changes: 16 additions & 23 deletions .travis.yml
@@ -1,28 +1,21 @@
language: python
sudo: false

python:
- '2.7'
- '3.5'
- '2.7'
- '3.5'
- '3.6'
- '3.7'
- '3.8'

install:
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh
-O miniconda.sh; else wget http://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
-O miniconda.sh; fi
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda info -a
- |
conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION pip numexpr numpy pandas scipy pytest
- source activate test-environment
- pip install pytest-cov coveralls pep8
- pip install .
- pip install .
- pip install -r requirements-dev.txt
- pip list
- pip show synthpop

script:
- pep8 synthpop
- py.test --cov synthpop --cov-report term-missing
- pycodestyle synthpop
- py.test --cov synthpop --cov-report term-missing

after_success:
- coveralls
notifications:
slack:
secure: AauAe1pvhJ/siv7ed2j34NAubBAMA9FaMuw7nFWk6i0lKQmhMh3ykqWY39OINpHe+4GJnedTpJQ1foZGYPSMZn5euEDqdtsg7SCzVQhlwFwD9jJ9a55HyZx6awYAbaxwGuSkrQ3glrSzG02ZgO9FnhCqAKk4TH9SI/sdEZ7W/7A=
- coveralls
12 changes: 12 additions & 0 deletions requirements-dev.txt
@@ -0,0 +1,12 @@
# Additional requirements for development and testing

# testing
coveralls
pytest
pytest-cov<2.10 # 2.10 raised errors in Travis
pycodestyle

# building documentation
numpydoc
sphinx
sphinx_rtd_theme
5 changes: 4 additions & 1 deletion setup.cfg
@@ -1,2 +1,5 @@
[pep8]
[pycodestyle]
# these are the standard ignores plus E402, E722, and E741, which weren't enforced when
# the codebase was first written
ignore = E121,E123,E126,E133,E226,E241,E242,E704,W503,W504,W505,E402,E722,E741
max-line-length = 100
6 changes: 3 additions & 3 deletions synthpop/ipu/test/test_ipu.py
Expand Up @@ -128,7 +128,7 @@ def test_update_weights(
household_freqs, person_freqs, household_constraints,
person_constraints):
column = household_freqs[('yes', 'blue')]
column = column.iloc[column.nonzero()[0]]
column = column.iloc[column.values.nonzero()[0]]
constraint = household_constraints[('yes', 'blue')]
weights = pd.Series(
np.ones(len(column)),
Expand All @@ -140,7 +140,7 @@ def test_update_weights(
atol=0.01)

column = person_freqs[(9, 'pink')]
column = column.iloc[column.nonzero()[0]]
column = column.iloc[column.values.nonzero()[0]]
constraint = person_constraints[(9, 'pink')]
weights = pd.Series(
[8.05, 9.51, 8.05, 10.59, 11.0, 8.97, 8.97, 8.97],
Expand All @@ -159,7 +159,7 @@ def test_household_weights(
household_freqs, person_freqs, household_constraints,
person_constraints, convergence=1e-7)
npt.assert_allclose(
weights.as_matrix(),
weights.values,
[1.36, 25.66, 7.98, 27.79, 18.45, 8.64, 1.47, 8.64],
atol=0.02)
npt.assert_allclose(fit_qual, 8.51e-6, atol=1e-8)
Expand Down
8 changes: 4 additions & 4 deletions synthpop/zone_synthesizer.py
Expand Up @@ -39,15 +39,15 @@ def load_data(hh_marginal_file, person_marginal_file,
p_sample = pd.read_csv(person_sample_file)

hh_marg = pd.read_csv(hh_marginal_file, header=[0, 1], index_col=0)
hh_marg.columns.levels[0].name = 'cat_name'
hh_marg.columns.levels[1].name = 'cat_values'
hh_marg.columns.levels[0].set_names('cat_name', inplace=True)
hh_marg.columns.levels[1].set_names('cat_values', inplace=True)

xwalk = list(zip(hh_marg.index, hh_marg.sample_geog.unstack().values))
hh_marg = hh_marg.drop('sample_geog', axis=1, level=0)

p_marg = pd.read_csv(person_marginal_file, header=[0, 1], index_col=0)
p_marg.columns.levels[0].name = 'cat_name'
p_marg.columns.levels[1].name = 'cat_values'
p_marg.columns.levels[0].set_names('cat_name', inplace=True)
p_marg.columns.levels[1].set_names('cat_values', inplace=True)

return hh_marg, p_marg, hh_sample, p_sample, xwalk

Expand Down

0 comments on commit b7de06e

Please sign in to comment.