|
7 | 7 | from os.path import (dirname, join as pjoin, abspath)
|
8 | 8 | import numpy as np
|
9 | 9 |
|
10 |
| -from hypothesis import given |
11 |
| -import hypothesis.strategies as st |
12 |
| - |
13 | 10 |
|
14 | 11 | DATA_PATH = abspath(pjoin(dirname(__file__), 'data'))
|
15 | 12 |
|
|
18 | 15 | # TODO: MAJOR TO DO IS TO FIGURE OUT HOW TO USE HYPOTHESIS FOR LONGER LIST LENGTHS WHILE STILL CONTROLLING FOR OUTCOMES
|
19 | 16 |
|
20 | 17 |
|
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) |
38 | 26 |
|
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) |
43 | 27 |
|
| 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.) |
44 | 35 |
|
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') |
50 | 36 |
|
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) |
54 | 42 | 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) |
56 | 44 |
|
57 | 45 |
|
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) |
65 | 49 |
|
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