Skip to content

Commit

Permalink
Pytest, github-actions, and codecov. (#114)
Browse files Browse the repository at this point in the history
* Create python-package-conda.yml

* delete travis.

* replace raw_input with input to support python3.

* add more python versions.

* update yaml to use multiple python versions.

* include pytest-cov.

* install.

* fix space.

* sync pytest with codecov.

* fix covfile name.

* replace test_dspec with pytest statements.

* migrate test_plot to pytest.

* migrate test_utils.

* migrate test_utils.

* remove 3.7
  • Loading branch information
aewallwi authored Apr 23, 2021
1 parent 3fe2074 commit 0e2b76e
Show file tree
Hide file tree
Showing 6 changed files with 260 additions and 247 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/python-package-conda.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Python Package using Conda

on: [push]

jobs:
build-linux:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.8, 3.9]
steps:
- uses: actions/checkout@v2
- name: Set up ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Add conda to system path
run: |
# $CONDA is an environment variable pointing to the root of the miniconda directory
echo $CONDA/bin >> $GITHUB_PATH
- name: Install dependencies
run: |
conda env update --file environment.yml --name base
- name: Lint with flake8
run: |
conda install flake8
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics
- name: Install
run: |
pip install .
- name: Test with pytest
run: |
conda install pytest
conda install pytest-cov
pytest --cov=./ --cov-report=xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage.xml
directory: ./coverage/reports/
flags: unittests
env_vars: OS,PYTHON
name: codecov-umbrella
fail_ci_if_error: true
path_to_write_report: ./coverage/codecov_report.txt
verbose: true
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

10 changes: 5 additions & 5 deletions scripts/plot_uv.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
help="Dynamic range in color of image, in units matching plotting mode. Default max(data)-min(data).")
o.add_option('-m', '--mode', dest='mode', default='log',
help='Plot mode can be log (logrithmic), abs (absolute), phs (phase), real, or imag.')
o.add_option('-t', '--time', dest='time', default='all',
o.add_option('-t', '--time', dest='time', default='all',
help='Select which time samples to plot. Options are: "all" (default), "<time1 #>_<time2 #>" (a range of times to plot), or "<time1 #>,<time2 #>" (a list of times to plot).')
o.add_option('-u', '--unmask', dest='unmask', action='store_true',
help='Plot masked data, too.')
Expand Down Expand Up @@ -128,7 +128,7 @@ def parse_range(chanstr):
plot_f['freq'] = meta['freqs'].flatten().take(chan)
plot_f['chan'] = chan
dat, flg, _ = uvf.read(bls, freq_chans=chan)
data.append(dat); flgs.append(flg)
data.append(dat); flgs.append(flg)

# Concatenate the data from all the files
if len(data) > 1:
Expand Down Expand Up @@ -243,7 +243,7 @@ def sort_func(a, b):
def click(event):
print([event.key])
if event.key == 'm':
mode = raw_input('Enter new mode: ')
mode = input('Enter new mode: ')
for k in plots:
try:
d = uvtools.plot.data_mode(plt_data[k], mode)
Expand All @@ -252,10 +252,10 @@ def click(event):
print('Unrecognized plot mode')
plt.draw()
elif event.key == 'd':
max = raw_input('Enter new max: ')
max = input('Enter new max: ')
try: max = float(max)
except(ValueError): max = None
drng = raw_input('Enter new drng: ')
drng = input('Enter new drng: ')
try: drng = float(drng)
except(ValueError): drng = None
for k in plots:
Expand Down
Loading

0 comments on commit 0e2b76e

Please sign in to comment.