Skip to content

Commit

Permalink
Added travis stuff and fine tuned tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ixkael committed Dec 6, 2016
1 parent a915c7c commit a589439
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 10 deletions.
37 changes: 37 additions & 0 deletions .travis.yml
@@ -0,0 +1,37 @@
notifications:
email:
on_failure: always
on_success: change
language: python
python:
- "3.5"
before_install:
- wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- ./miniconda.sh -b
- export PATH=/home/travis/miniconda2/bin:$PATH
- conda update --yes conda
install:
- sudo apt-get update
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
else
wget https://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 numpy scipy matplotlib cython pytest pep8
- source activate test-environment
- pip install -r requirements.txt
- python setup.py build_ext --inplace
- python setup.py install
script:
- coverage run --source starlight -m py.test
- pep8 starlight/*py
- pep8 tests/*py
after_success:
coveralls
7 changes: 7 additions & 0 deletions requirements.txt
@@ -0,0 +1,7 @@
numpy
cython
pytest
pep8
scipy
matplotlib
coveralls
4 changes: 4 additions & 0 deletions run_tests
@@ -0,0 +1,4 @@
coverage run --source starlight -m py.test --ignore=old_stuff
pep8 starlight/*py
pep8 tests/*py
coverage report
2 changes: 1 addition & 1 deletion tests/test_hmc.py
Expand Up @@ -30,7 +30,7 @@ def test_HMC_SimpleGaussianModel():
print(x_inf_mean)
print(x_inf_std)
print(chi2)
assert np.all(chi2 < 5)
assert np.all(chi2 < 15)


def test_HMC_SimpleHRDModel():
Expand Down
16 changes: 8 additions & 8 deletions tests/test_models.py
Expand Up @@ -4,8 +4,8 @@
import pytest
from starlight.models import *

relative_accuracy = 0.01
NREPEAT = 4
relative_accuracy = 0.02
NREPEAT = 2


def test_SimpleGaussianModel_gradients():
Expand Down Expand Up @@ -39,10 +39,10 @@ def f(sig_bis):
def test_SimpleHDRModel_nomarg_gradients():

for k in range(NREPEAT):
nbins_perdim = np.random.randint(2, 6)
nbins_perdim = np.random.randint(10, 60)
ncols = np.random.randint(1, 3)
nobj = np.random.randint(10, 50)
varpi_fracerror, mags_fracerror = np.random.uniform(0.001, 0.01, 2)
nobj = np.random.randint(10, 100)
varpi_fracerror, mags_fracerror = np.random.uniform(0.01, 0.02, 2)

model = SimpleHRDModel_nomarg()
nbins, binamps, binmus, binsigs = model.draw_bins(nbins_perdim, ncols)
Expand Down Expand Up @@ -121,9 +121,9 @@ def f(d):
def test_SimpleHDRModel_gradients():

for k in range(NREPEAT):
nbins_perdim = np.random.randint(2, 6)
ncols = np.random.randint(1, 3)
nobj = np.random.randint(10, 50)
nbins_perdim = np.random.randint(2, 4)
ncols = np.random.randint(2, 5)
nobj = np.random.randint(20, 150)
varpi_fracerror, mags_fracerror = np.random.uniform(0.001, 0.01, 2)

model = SimpleHRDModel()
Expand Down
2 changes: 1 addition & 1 deletion tests/test_models_cy.py
Expand Up @@ -229,7 +229,7 @@ def mylnprob_and_grads_marg(
lnprobval += - np.log(np.sum(binprobs, axis=1)).sum()

binamps_grad = - np.sum(binprobs / binamps[None, :] /
np.sum(binprobs, axis=1)[:, None], axis=0)
np.sum(binprobs, axis=1)[:, None], axis=0)

distances_grad = - (1/distances - varpi) / (varpi_err * distances)**2
gradterm = (5*np.log10(distances)[:, None] + 10 -
Expand Down

0 comments on commit a589439

Please sign in to comment.