Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test suite with GitHub action and test coverage #46

Merged
merged 9 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Testing

on: [push]

jobs:
build:

runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9"]

steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies manually
run: |
pip install future matplotlib cartopy pandas requests seaborn jupyter-book scikit-learn ipywidgets
pip install pmagpy==4.2.106
pip install -e ./smpsite
pip install flake8 pytest pytest-cov
- name: Lint with flake8
run: |
# 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: Test with pytest
run: |
pytest smpsite --cov --cov-report=html:coverage_re
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
# with:
# directory: ./smpsite
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ For a detailed description of the project, take a look at [our preprint of a man
[![DOI](https://zenodo.org/badge/595793364.svg)](https://zenodo.org/badge/latestdoi/595793364)
[![Jupyter Book Badge](https://jupyterbook.org/badge.svg)](https://polarwandering.github.io/PaleoSampling/)
[![Build Status](https://github.com/PolarWandering/PaleoSampling/actions/workflows/book.yml/badge.svg?branch=main)](https://github.com/PolarWandering/PaleoSampling/actions/workflows/book.yml?query=branch%3Amain)
![Tests Passing](https://github.com/github/docs/actions/workflows/test.yml/badge.svg)
[![codecov](https://codecov.io/gh/PolarWandering/PaleoSampling/graph/badge.svg?token=L3WO0AEN90)](https://codecov.io/gh/PaleoWandering/PaleoSampling)
[![All Contributors](https://img.shields.io/github/all-contributors/PolarWandering/PaleoSampling?color=ee8449&style=flat-square)](#contributors)


Expand Down
Empty file.
12 changes: 12 additions & 0 deletions smpsite/smpsite/test/test_execution.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import numpy as np
from numpy.testing import assert_allclose
import smpsite as smp

def test_run_kappa_from_latitude():
_res = smp.kappa_from_latitude(10.0, degrees=True)
assert isinstance(_res, np.ndarray)
assert _res.shape == ()

def test_run_lat_correction():
_res = smp.lat_correction(30.0, degrees=True)
assert_allclose(_res, 1.2578124999999998, atol=1e-6)