diff --git a/tests/test_models.py b/tests/test_models.py index 372440f..63a602a 100644 --- a/tests/test_models.py +++ b/tests/test_models.py @@ -2,82 +2,77 @@ import numpy as np import numpy.testing as npt +import pytest +@pytest.mark.parametrize( + "test, expected", + [ + ([ [0, 0], [0, 0], [0, 0] ], [0, 0]), + ([ [1, 2], [3, 4], [5, 6] ], [3, 4]), + ([[-1, 2, 3], [4, -5, 6], [7, 8, -9] ], [3.33333333, 1.66666667, 0.]) + ] +) -def test_daily_mean_zeros(): +def test_daily_mean(test, expected): """Test that mean function works for an array of zeros.""" from inflammation.models import daily_mean - test_input = np.array([[0, 0], - [0, 0], - [0, 0]]) - test_result = np.array([0, 0]) - - # Need to use Numpy testing functions to compare arrays - npt.assert_array_equal(daily_mean(test_input), test_result) - - -def test_daily_mean_integers(): - """Test that mean function works for an array of positive integers.""" - from inflammation.models import daily_mean - - test_input = np.array([[1, 2], - [3, 4], - [5, 6]]) - test_result = np.array([3, 4]) - # Need to use Numpy testing functions to compare arrays - npt.assert_array_equal(daily_mean(test_input), test_result) - -def test_daily_mean_pos_and_neg_integers(): - """Test that mean function works for an array of positive and negative integers.""" - from inflammation.models import daily_mean - - test_input = np.array([[-1, 2, 3], - [4, -5, 6], - [7, 8, -9]]) - test_result = np.array([3.33333333, 1.66666667, 0.]) + npt.assert_array_almost_equal(daily_mean(np.array(test)), np.array(expected)) + +@pytest.mark.parametrize( + "test, expected", + [ + ([ [0, 0], [0, 0], [0, 0] ], [0, 0]), + ([ [1, 2], [3, 4], [5, 6] ], [5, 6]), + ([[-1, 2, 3], [4, -5, 6], [7, 8, -9] ], [7, 8, 6]) + ] +) + +def test_daily_max(test, expected): + """Test that max function works for an array of zeros.""" + from inflammation.models import daily_max # Need to use Numpy testing functions to compare arrays - npt.assert_array_almost_equal(daily_mean(test_input), test_result) + npt.assert_array_equal(daily_max(np.array(test)), np.array(expected)) -def test_daily_max_zeros(): - """Test that max function works for an array of zeros.""" - from inflammation.models import daily_max +# def test_daily_max_zeros(): +# """Test that max function works for an array of zeros.""" +# from inflammation.models import daily_max - test_input = np.array([[0, 0], - [0, 0], - [0, 0]]) - test_result = np.array([0, 0]) +# test_input = np.array([[0, 0], +# [0, 0], +# [0, 0]]) +# test_result = np.array([0, 0]) - # Need to use Numpy testing functions to compare arrays - npt.assert_array_equal(daily_max(test_input), test_result) +# # Need to use Numpy testing functions to compare arrays +# npt.assert_array_equal(daily_max(test_input), test_result) -def test_daily_max_integers(): - """Test that max function works for an array of positive integers.""" - from inflammation.models import daily_max +# def test_daily_max_integers(): +# """Test that max function works for an array of positive integers.""" +# from inflammation.models import daily_max - test_input = np.array([[1, 2], - [3, 4], - [5, 6]]) - test_result = np.array([5, 6]) +# test_input = np.array([[1, 2], +# [3, 4], +# [5, 6]]) +# test_result = np.array([5, 6]) - # Need to use Numpy testing functions to compare arrays - npt.assert_array_equal(daily_max(test_input), test_result) +# # Need to use Numpy testing functions to compare arrays +# npt.assert_array_equal(daily_max(test_input), test_result) -def test_daily_max_floats(): - """Test that max function works for an array of positive floats.""" - from inflammation.models import daily_max +# def test_daily_max_floats(): +# """Test that max function works for an array of positive floats.""" +# from inflammation.models import daily_max - test_input = np.array([[1.1, 2.2], - [3.3, 4.4], - [5.5, 6.6]]) - test_result = np.array([5.5, 6.6]) +# test_input = np.array([[1.1, 2.2], +# [3.3, 4.4], +# [5.5, 6.6]]) +# test_result = np.array([5.5, 6.6]) - # Need to use Numpy testing functions to compare arrays - npt.assert_array_equal(daily_max(test_input), test_result) +# # Need to use Numpy testing functions to compare arrays +# npt.assert_array_equal(daily_max(test_input), test_result) def test_daily_min_zeros(): """Test that min function works for an array of zeros.""" @@ -129,7 +124,7 @@ def test_daily_min_pos_and_neg_integers(): npt.assert_array_equal(daily_min(test_input), test_result) ... -import pytest + def test_daily_min_string(): """Test for TypeError when passing strings""" from inflammation.models import daily_min