Skip to content

Commit

Permalink
added CI
Browse files Browse the repository at this point in the history
  • Loading branch information
JohannesBuchner committed Nov 27, 2017
1 parent 2164574 commit f199a06
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 7 deletions.
23 changes: 23 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# .coveragerc to control coverage.py
#

[run]
branch = True
omit =
doc/tests/*
setup.py


[report]
exclude_lines =
pragma: no cover
def __repr__
if __name__ == .__main__.:
omit =
.eggs/*
/home/travis/.local/lib/*
test*.py
setup.py
__init__.py

85 changes: 85 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
language: python

sudo: false

python:
- "2.7"
# - "3.4"
# - "3.5"

git:
depth: 10000

env:


install:
# Fetch and install conda
# -----------------------
- export CONDA_BASE="http://repo.continuum.io/miniconda/Miniconda"
- if [[ "${TRAVIS_PYTHON_VERSION}" == 2* ]]; then
wget ${CONDA_BASE}2-latest-Linux-x86_64.sh -O miniconda.sh;
else
wget ${CONDA_BASE}3-latest-Linux-x86_64.sh -O miniconda.sh;
fi
- bash miniconda.sh -b -p ${HOME}/miniconda
- export PATH="${HOME}/miniconda/bin:${PATH}"

# Create the testing environment
# ------------------------------
- conda config --set always_yes true
- conda config --set changeps1 no
- conda config --set show_channel_urls true
- conda config --add channels conda-forge
- conda update --quiet conda
- ENV_NAME="test-environment"
- conda create --quiet -n ${ENV_NAME} python=${TRAVIS_PYTHON_VERSION}
- source activate ${ENV_NAME}

# Customise the testing environment
# ---------------------------------
- conda install --quiet --file conda-requirements.txt
- pip install coveralls

# Summerise environment
# ---------------------
- conda list
- conda info -a

# Install and test imagehash
- python setup.py install

script:
- coverage run setup.py test
# 2 catalogue match
- nway.py COSMOS_XMM.fits :pos_err COSMOS_OPTICAL.fits 0.1 --out=example2.fits --radius 20
- nway.py XMM_xray_offset_clean_errors.fits :pos_err COSMOS_OPTICAL.fits 0.1 --out=example2-offset.fits --radius 20

# 2 catalogue match, with magnitudes

- nway.py COSMOS_XMM.fits :pos_err COSMOS_OPTICAL.fits 0.1 --out=example2-mag.fits --radius 20 --mag OPT:MAG auto --mag-radius=4
- nway.py XMM_xray_offset_clean_errors.fits :pos_err COSMOS_OPTICAL.fits 0.1 --out=example2-mag-offset.fits --radius 20 --mag OPT:MAG OPT_MAG_fit.txt

# 3 catalogue match
- nway.py COSMOS_XMM.fits :pos_err COSMOS_OPTICAL.fits 0.1 COSMOS_IRAC.fits 0.5 --out=example3.fits --radius 20
- nway.py XMM_xray_offset_clean_errors.fits :pos_err COSMOS_OPTICAL.fits 0.1 COSMOS_IRAC.fits 0.5 --out=example3-offset.fits --radius 20

# 3 catalogue match, with magnitudes

- nway.py --radius 20 COSMOS_XMM.fits :pos_err COSMOS_OPTICAL.fits 0.1 COSMOS_IRAC.fits 0.5 --mag OPT:MAG auto --mag IRAC:mag_ch1 auto --mag-radius 4 --out=example3-mag.fits
- nway.py XMM_xray_offset_clean_errors.fits :pos_err COSMOS_OPTICAL.fits 0.1 COSMOS_IRAC.fits 0.5 --out=example3-mag-offset.fits --radius 20 --mag OPT:MAG OPT_MAG_fit.txt --mag IRAC:mag_ch1 IRAC_mag_ch1_fit.txt

# create fake catalogues
- nway-create-fake-catalogue --radius 20 COSMOS_XMM.fits example2-fake-offset.fits
- nway-create-shifted-catalogue --radius 20 COSMOS_XMM.fits example2-fake-offset.fits
- nway-explain.py example3-offset.fits 422

- nway-calibrate-cutoff.py example2.fits example2-offset.fits
- nway-calibrate-cutoff.py python cutoffquality.py example2-mag.fits example2-mag-offset.fits
- nway-calibrate-cutoff.py example3.fits example3-offset.fits
- nway-calibrate-cutoff.py example3-mag.fits example3-mag-offset.fits

# we should test for created output files
- ls

after_success: coveralls
8 changes: 8 additions & 0 deletions conda-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
scipy
numpy
astropy
progressbar-latest
matplotlib
argparse
joblib
healpy
14 changes: 8 additions & 6 deletions nway.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,12 @@ def error(self, message):
# get column
k = "%s_%s" % (table_name, pos_error[1:])
assert k in table.dtype.names, 'ERROR: Position error column for "%s" not in table "%s". Have these columns: %s' % (k, table_name, ', '.join(table.dtype.names))
print(' Position error for "%s": found column %s: Values are [%f..%f]' % (table_name, k, table[k].min(), table[k].max()))
if tables[ti][pos_error[1:]].min() <= 0:
print('WARNING: Some separation errors in "%s" are 0! This will give invalid results (%d rows).' % (k, (tables[ti][pos_error[1:]] <= 0).sum()))
if table[k].max() > match_radius * 60 * 60:
print('WARNING: Some separation errors in "%s" are larger than the match radius! Increase --radius to >> %s' % (k, table[k].max()))
table_errors = tables[ti][pos_error[1:]]
print(' Position error for "%s": found column %s: Values are [%f..%f]' % (table_name, k, table_errors.min(), table_errors.max()))
if table_errors.min() <= 0:
print('WARNING: Some separation errors in "%s" are 0! This will give invalid results (%d rows).' % (k, (table_errors <= 0).sum()))
if table_errors.max() > match_radius * 60 * 60:
print('WARNING: Some separation errors in "%s" are larger than the match radius! Increase --radius to >> %s' % (k, table_errors.max()))
errors.append(table[k])
else:
print(' Position error for "%s": using fixed value %f' % (table_name, float(pos_error)))
Expand Down Expand Up @@ -493,7 +494,8 @@ def error(self, message):
print(' writing "%s" (%d rows, %d columns) ...' % (outfile, len(tbhdu.data), len(columns)))
hdulist.writeto(outfile, clobber=True)


import nwaylib.checkupdates
nwaylib.checkupdates.checkupdates()



1 change: 1 addition & 0 deletions nwaylib/VERSION
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.7
2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
[wheel]
universal = 1
[aliases]
test=pytest
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

setup(
name='nway',
version='3.7',
version=open(os.path.join('nwaylib', 'VERSION')).read().strip(),
author='Johannes Buchner',
author_email='johannes.buchner.acad@gmx.com',
packages=['nwaylib'],
Expand All @@ -28,6 +28,8 @@
"joblib",
"healpy",
],
setup_requires=['pytest-runner'],
tests_require=['pytest'],
)


0 comments on commit f199a06

Please sign in to comment.