Skip to content

Commit

Permalink
Merge pull request #4 from nstelter-slac/simple_test_and_actions
Browse files Browse the repository at this point in the history
TST: Add simple test of some fit-functions and file to run in github actions
  • Loading branch information
nstelter-slac authored Jan 18, 2024
2 parents 278c2e5 + 0035019 commit af8ceb8
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
27 changes: 27 additions & 0 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Run Tests

on: [push, pull_request]

jobs:
test:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: 3.8

- name: Install dependencies
run: |
pip install pytest
pip install numpy
pip install scipy
pip install statsmodels
- name: Run tests
run: |
pytest testFitFunctions.py # Replace with your actual test file name
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# beamtime-calibration-suite
# beamtime-calibration-suite
[![Build Status](https://github.com/slaclab/beamtime-calibration-suite/actions/workflows/run-tests.yml/badge.svg?branch=master)](https://github.com/slaclab/beamtime-calibration-suite/actions/workflows/run-tests.yml)
15 changes: 15 additions & 0 deletions testFitFunctions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import numpy as np
import pytest
from fitFunctions import linear, saturatedLinear

@pytest.mark.parametrize("a, b, expected", [(2, 3, np.array([5, 7, 9, 11, 13]))])
def test_linear(a, b, expected):
x = np.array([1, 2, 3, 4, 5])
result = linear(x, a, b)
np.testing.assert_array_equal(result, expected)

@pytest.mark.parametrize("a, b, c, d, expected", [(2, 3, 4, 10, np.array([5, 7, 9, 10, 10]))])
def test_saturatedLinear(a, b, c, d, expected):
x = np.array([1, 2, 3, 4, 5])
result = saturatedLinear(x, a, b, c, d)
np.testing.assert_array_equal(result, expected)

0 comments on commit af8ceb8

Please sign in to comment.