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

Use hypothesis for tests #11

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion buildscripts/incremental/build.cmd
Original file line number Diff line number Diff line change
@@ -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%
2 changes: 1 addition & 1 deletion buildscripts/incremental/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]
22 changes: 18 additions & 4 deletions numba_scipy/tests/test_special.py
Original file line number Diff line number Diff line change
@@ -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))
6 changes: 6 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
packages=['numba_scipy'],
setup_requires=[],
install_requires=_install_requires,
extras_require={
"dev": [
"pytest",
"hypothesis[numpy]",
],
},
license="BSD",
zip_safe=False,
)
Expand Down