From d52be2d94bf9f439da41396e06ca33dbf9d33d19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Luis=20Cano=20Rodr=C3=ADguez?= Date: Fri, 9 Aug 2019 18:32:26 +0200 Subject: [PATCH 1/3] Use hypothesis for tests --- numba_scipy/tests/test_special.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/numba_scipy/tests/test_special.py b/numba_scipy/tests/test_special.py index 9dae6bb..19f171d 100644 --- a/numba_scipy/tests/test_special.py +++ b/numba_scipy/tests/test_special.py @@ -1,17 +1,31 @@ """Tests the scipy.special bindings """ -import numba_scipy.special # noqa +import numba_scipy.special # noqa from scipy.special import beta from numba import njit import numpy as np +from hypothesis import given, settings +import hypothesis.strategies as st +from hypothesis.extra.numpy import arrays as st_arrays -def test_beta(): +@given(st.floats(0, 20), st.floats(0, 20)) +def test_beta_scalars(x, y): + @njit + def test_impl(a, b): + return beta(a, b) + + np.testing.assert_allclose(test_impl(x, y), test_impl.py_func(x, y)) + + +@given( + st_arrays(np.float, 10, st.floats(0, 20)), st_arrays(np.float, 10, st.floats(0, 20)) +) +@settings(deadline=None) +def test_beta_arrays(x, y): @njit def test_impl(a, b): return beta(a, b) - x = np.linspace(0, 20, 50) - y = x[::-1] np.testing.assert_allclose(test_impl(x, y), test_impl.py_func(x, y)) From d16038f5e55f77c5a5d749171c9ffc1dae3d0097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Luis=20Cano=20Rodr=C3=ADguez?= Date: Fri, 9 Aug 2019 18:41:25 +0200 Subject: [PATCH 2/3] Add test dependencies to setup.py --- setup.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/setup.py b/setup.py index 310e3be..73eaed3 100644 --- a/setup.py +++ b/setup.py @@ -29,6 +29,12 @@ packages=['numba_scipy'], setup_requires=[], install_requires=_install_requires, + extras_require={ + "dev": [ + "pytest", + "hypothesis[numpy]", + ], + }, license="BSD", zip_safe=False, ) From cc7963f017f5e9b711eaf2593d02315296571daf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Luis=20Cano=20Rodr=C3=ADguez?= Date: Fri, 9 Aug 2019 18:41:33 +0200 Subject: [PATCH 3/3] Install test dependencies in CI --- buildscripts/incremental/build.cmd | 2 +- buildscripts/incremental/build.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/buildscripts/incremental/build.cmd b/buildscripts/incremental/build.cmd index 7cf3ea9..93af2be 100644 --- a/buildscripts/incremental/build.cmd +++ b/buildscripts/incremental/build.cmd @@ -1,6 +1,6 @@ call activate %CONDA_ENV% -python -m pip install -e . +python -m pip install -e .[dev] if %errorlevel% neq 0 exit /b %errorlevel% diff --git a/buildscripts/incremental/build.sh b/buildscripts/incremental/build.sh index 90453d3..ebf0938 100755 --- a/buildscripts/incremental/build.sh +++ b/buildscripts/incremental/build.sh @@ -5,4 +5,4 @@ source activate $CONDA_ENV # Make sure any error below is reported as such set -v -e -python -m pip install -e . +python -m pip install -e .[dev]