Skip to content

Commit e8d3a4f

Browse files
committed
RF: do not use hypothesis
Proved to give some troubles along the way and its use was quite basic and only in one tests module. So - replaced with simpler straightforward tests
1 parent 7877add commit e8d3a4f

File tree

4 files changed

+31
-47
lines changed

4 files changed

+31
-47
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ cache:
1313
- $HOME/.cache/pip
1414
env:
1515
global:
16-
- DEPENDS="six numpy scipy matplotlib h5py pillow pydicom hypothesis"
16+
- DEPENDS="six numpy scipy matplotlib h5py pillow pydicom"
1717
- OPTIONAL_DEPENDS=""
1818
- INSTALL_TYPE="setup"
1919
- EXTRA_WHEELS="https://5cf40426d9f06eb7461d-6fe47d9331aba7cd62fc36c7196769e4.ssl.cf2.rackcdn.com"
@@ -97,7 +97,7 @@ before_install:
9797
- source venv/bin/activate
9898
- python --version # just to check
9999
- pip install -U pip wheel # needed at one point
100-
- retry pip install nose flake8 mock hypothesis # always
100+
- retry pip install nose flake8 mock # always
101101
- pip install $EXTRA_PIP_FLAGS $DEPENDS $OPTIONAL_DEPENDS
102102
- if [ "${COVERAGE}" == "1" ]; then
103103
pip install coverage;

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ install:
2222
- SET PATH=%PYTHON%;%PYTHON%\Scripts;%PATH%
2323

2424
# Install the dependencies of the project.
25-
- pip install numpy scipy matplotlib nose h5py mock hypothesis pydicom
25+
- pip install numpy scipy matplotlib nose h5py mock pydicom
2626
- pip install .
2727
- SET NIBABEL_DATA_DIR=%CD%\nibabel-data
2828

dev-requirements.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@
22
-r requirements.txt
33
nose
44
mock
5-
hypothesis

nibabel/tests/test_diff.py

Lines changed: 28 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
from os.path import (dirname, join as pjoin, abspath)
88
import numpy as np
99

10-
from hypothesis import given
11-
import hypothesis.strategies as st
12-
1310

1411
DATA_PATH = abspath(pjoin(dirname(__file__), 'data'))
1512

@@ -18,51 +15,39 @@
1815
# TODO: MAJOR TO DO IS TO FIGURE OUT HOW TO USE HYPOTHESIS FOR LONGER LIST LENGTHS WHILE STILL CONTROLLING FOR OUTCOMES
1916

2017

21-
@given(st.data())
22-
def test_diff_values_int(data):
23-
x = data.draw(st.integers(), label='x')
24-
y = data.draw(st.integers(min_value=x + 1), label='x+1')
25-
z = data.draw(st.integers(max_value=x - 1), label='x-1')
26-
27-
assert not are_values_different(x, x)
28-
assert are_values_different(x, y)
29-
assert are_values_different(x, z)
30-
assert are_values_different(y, z)
31-
32-
33-
@given(st.data())
34-
def test_diff_values_float(data):
35-
x = data.draw(st.just(0), label='x')
36-
y = data.draw(st.floats(min_value=1e8), label='y')
37-
z = data.draw(st.floats(max_value=-1e8), label='z')
18+
def test_diff_values_int():
19+
long = 10**30
20+
assert not are_values_different(0, 0)
21+
assert not are_values_different(1, 1)
22+
assert not are_values_different(long, long)
23+
assert are_values_different(0, 1)
24+
assert are_values_different(1, 2)
25+
assert are_values_different(1, long)
3826

39-
assert not are_values_different(x, x)
40-
assert are_values_different(x, y)
41-
assert are_values_different(x, z)
42-
assert are_values_different(y, z)
4327

28+
def test_diff_values_float():
29+
assert not are_values_different(0., 0.)
30+
assert not are_values_different(0., 0., 0.) # can take more
31+
assert not are_values_different(1.1, 1.1)
32+
assert are_values_different(0., 1.1)
33+
assert are_values_different(0., 0, 1.1)
34+
assert are_values_different(1., 2.)
4435

45-
@given(st.data())
46-
def test_diff_values_mixed(data):
47-
type_float = data.draw(st.floats(), label='float')
48-
type_int = data.draw(st.integers(), label='int')
49-
type_none = data.draw(st.none(), label='none')
5036

51-
assert are_values_different(type_float, type_int)
52-
assert are_values_different(type_float, type_none)
53-
assert are_values_different(type_int, type_none)
37+
def test_diff_values_mixed():
38+
assert are_values_different(1.0, 1)
39+
assert are_values_different(1.0, "1")
40+
assert are_values_different(1, "1")
41+
assert are_values_different(1, None)
5442
assert are_values_different(np.ndarray([0]), 'hey')
55-
assert not are_values_different(type_none, type_none)
43+
assert not are_values_different(None, None)
5644

5745

58-
@given(st.data())
59-
def test_diff_values_array(data):
60-
a = data.draw(st.lists(elements=st.integers(min_value=0), min_size=1))
61-
b = data.draw(st.lists(elements=st.integers(max_value=-1), min_size=1))
62-
c = data.draw(st.lists(elements=st.floats(min_value=1e8), min_size=1))
63-
d = data.draw(st.lists(elements=st.floats(max_value=-1e8), min_size=1))
64-
# TODO: Figure out a way to include 0 in lists (arrays)
46+
def test_diff_values_array():
47+
a_int = np.array([1, 2])
48+
a_float = a_int.astype(float)
6549

66-
assert are_values_different(a, b)
67-
assert are_values_different(c, d)
68-
assert not are_values_different(a, a)
50+
#assert are_values_different(a_int, a_float)
51+
assert are_values_different(np.arange(3), np.arange(1, 4))
52+
assert not are_values_different(a_int, a_int)
53+
assert not are_values_different(a_float, a_float)

0 commit comments

Comments
 (0)