-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
171 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
tests/input/** filter=lfs diff=lfs merge=lfs -text |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,13 +12,57 @@ on: | |
- cron: '0 6 1 * *' # once a month in the morning | ||
|
||
jobs: | ||
# Use the `flake8` tool to check for syntax errors | ||
flake8: | ||
name: Flake8 | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Setup Python 3.7 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.7 | ||
|
||
- name: Cache pip | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-py3.7-${{ hashFiles('requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip-py3.7- | ||
${{ runner.os }}-pip- | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip wheel | ||
grep "numpy" requirements.txt | xargs -I {} pip install "{}" | ||
pip install -r requirements.txt | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
# For some reason we have to specifically ignore G001 as well | ||
flake8 --select=E9,F63,F7,F82 --ignore=G001 --show-source | ||
# exit-zero treats all errors as warnings. | ||
flake8 --exit-zero | ||
# Run unit tests on Linux, OSX and Windows | ||
pytest: | ||
needs: flake8 | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
python-version: [3.6, 3.7, 3.8] | ||
include: | ||
- os: ubuntu-latest | ||
pippath: ~/.cache/pip | ||
- os: macos-latest | ||
pippath: ~/Library/Caches/pip | ||
- os: windows-latest | ||
pippath: ~\AppData\Local\pip\Cache | ||
|
||
name: Python ${{ matrix.python-version }} on ${{ matrix.os }} | ||
runs-on: ${{ matrix.os }} | ||
|
@@ -33,11 +77,33 @@ jobs: | |
with: | ||
fetch-depth: 0 | ||
|
||
- name: Create LFS file list | ||
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id | ||
|
||
- name: Restore LFS cache | ||
uses: actions/cache@v2 | ||
id: lfs-cache | ||
with: | ||
path: .git/lfs | ||
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1 | ||
|
||
- name: Git LFS Pull | ||
run: git lfs pull | ||
|
||
- name: Setup Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
|
||
- name: Cache pip | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ matrix.pippath }} | ||
key: ${{ runner.os }}-pip-py${{ matrix.python-version }}-${{ hashFiles('requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip-py${{ matrix.python-version }}- | ||
${{ runner.os }}-pip- | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip wheel | ||
|
@@ -53,30 +119,76 @@ jobs: | |
with: | ||
env_vars: OS,PYTHON | ||
|
||
|
||
# Use the `flake8` tool to check for syntax errors | ||
flake8: | ||
name: Flake8 | ||
# Release tagged commits to: | ||
release: | ||
name: Create release | ||
if: startsWith( github.ref, 'refs/tags/v' ) | ||
needs: pytest | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Create LFS file list | ||
run: git lfs ls-files -l | cut -d' ' -f1 | sort > .lfs-assets-id | ||
|
||
- name: Restore LFS cache | ||
uses: actions/cache@v2 | ||
id: lfs-cache | ||
with: | ||
path: .git/lfs | ||
key: ${{ runner.os }}-lfs-${{ hashFiles('.lfs-assets-id') }}-v1 | ||
|
||
- name: Git LFS Pull | ||
run: git lfs pull | ||
|
||
- name: Setup Python 3.7 | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.7 | ||
|
||
- name: Cache pip | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.cache/pip | ||
key: ${{ runner.os }}-pip-py3.7-${{ hashFiles('requirements.txt') }} | ||
restore-keys: | | ||
${{ runner.os }}-pip-py3.7- | ||
${{ runner.os }}-pip- | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip wheel | ||
grep "numpy" requirements.txt | xargs -I {} pip install "{}" | ||
pip install -r requirements.txt | ||
- name: Lint with flake8 | ||
run: | | ||
# stop the build if there are Python syntax errors or undefined names | ||
# For some reason we have to specifically ignore G001 as well | ||
flake8 --select=E9,F63,F7,F82 --ignore=G001 --show-source | ||
# exit-zero treats all errors as warnings. | ||
flake8 --exit-zero | ||
- name: Update VERSION file | ||
run: python -c "from flows import version; version.update_release_version();" | ||
|
||
- name: Set env | ||
id: vars | ||
run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/v} | ||
|
||
- name: Generate changelog | ||
id: changelog | ||
uses: metcalfc/[email protected] | ||
with: | ||
myToken: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Create Release | ||
id: create_release | ||
uses: actions/create-release@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
tag_name: ${{ github.ref }} | ||
release_name: Version ${{ steps.vars.outputs.tag }} | ||
body: | | ||
Version ${{ steps.vars.outputs.tag }} | ||
Changelog | ||
--------- | ||
${{ steps.changelog.outputs.changelog }} | ||
draft: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
master-v0.7.8 | ||
master-v0.7.9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Git LFS file not shown
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env python3 | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Test loading of images. | ||
.. codeauthor:: Rasmus Handberg <[email protected]> | ||
""" | ||
|
||
import pytest | ||
import numpy as np | ||
from astropy.time import Time | ||
from astropy.wcs import WCS | ||
import os.path | ||
import conftest | ||
from flows.load_image import load_image | ||
|
||
#-------------------------------------------------------------------------------------------------- | ||
@pytest.mark.parametrize('fpath', ['SN2020aatc_K_20201213_495s.fits.gz']) | ||
def test_load_image(fpath): | ||
|
||
# The test input directory containing the test-images: | ||
INPUT_DIR = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'input') | ||
|
||
# Load the image from the test-set: | ||
img = load_image(os.path.join(INPUT_DIR, fpath)) | ||
|
||
# Check the attributes of the image object: | ||
assert isinstance(img.image, np.ndarray) | ||
assert img.image.dtype in ('float32', 'float64') | ||
assert isinstance(img.mask, np.ndarray) | ||
assert img.mask.dtype == 'bool' | ||
assert isinstance(img.clean, np.ma.MaskedArray) | ||
assert img.clean.dtype == img.image.dtype | ||
assert isinstance(img.obstime, Time) | ||
assert isinstance(img.exptime, float) | ||
assert img.exptime > 0 | ||
assert isinstance(img.photfilter, str) | ||
assert isinstance(img.wcs, WCS) | ||
|
||
#-------------------------------------------------------------------------------------------------- | ||
if __name__ == '__main__': | ||
pytest.main([__file__]) |