8
8
from datetime import date
9
9
from dateutil import relativedelta
10
10
11
- from pandas .util ._hypothesis import (st ,
12
- given ,
13
- settings ,
14
- get_seq ,
15
- assume )
16
-
11
+ from pandas .util import _hypothesis as hp
17
12
18
13
NO_OF_EXAMPLES_PER_TEST_CASE = 20
19
14
20
15
21
16
class TestCartesianProduct (object ):
22
17
23
- @settings (max_examples = NO_OF_EXAMPLES_PER_TEST_CASE )
24
- @given (get_seq ((str ,), False , 1 , 1 ),
25
- get_seq ((int ,), False , 1 , 2 ))
18
+ @hp .settings (max_examples = 20 )
19
+ @hp .given (hp .st .lists (hp .st .text (string .ascii_letters , min_size = 1 , max_size = 1 ),
20
+ min_size = 1 , max_size = 3 ),
21
+ hp .get_seq ((int ,), False , 1 , 2 ))
26
22
def test_simple (self , x , y ):
27
- x = list (x [0 ])
28
- # non-empty test case is handled in test_empty,
29
- # therefore ignore it here.
30
- assume (len (x ) != 0 )
31
23
result1 , result2 = cartesian_product ([x , y ])
32
24
expected1 = np .array ([item1 for item1 in x for item2 in y ])
33
25
expected2 = np .array ([item2 for item1 in x for item2 in y ])
34
26
35
27
tm .assert_numpy_array_equal (result1 , expected1 )
36
28
tm .assert_numpy_array_equal (result2 , expected2 )
37
29
38
- @settings (max_examples = NO_OF_EXAMPLES_PER_TEST_CASE )
39
- @given (st .dates (min_value = date (1900 , 1 , 1 ), max_value = date (2100 , 1 , 1 )))
30
+ @hp . settings (max_examples = 20 )
31
+ @hp . given (hp . st .dates (min_value = date (1900 , 1 , 1 ), max_value = date (2100 , 1 , 1 )))
40
32
def test_datetimeindex (self , d ):
41
33
# regression test for GitHub issue #6439
42
34
# make sure that the ordering on datetimeindex is consistent
@@ -49,10 +41,10 @@ def test_datetimeindex(self, d):
49
41
tm .assert_index_equal (result1 , expected1 )
50
42
tm .assert_index_equal (result2 , expected2 )
51
43
52
- @settings (max_examples = NO_OF_EXAMPLES_PER_TEST_CASE )
53
- @given (st .lists (st .nothing ()),
54
- get_seq ((int ,), False , min_size = 1 , max_size = 10 ),
55
- get_seq ((str ,), False , min_size = 1 , max_size = 10 ))
44
+ @hp . settings (max_examples = 20 )
45
+ @hp . given (hp . st .lists (hp . st .nothing ()),
46
+ hp . get_seq ((int ,), False , min_size = 1 , max_size = 10 ),
47
+ hp . get_seq ((str ,), False , min_size = 1 , max_size = 10 ))
56
48
def test_empty (self , empty_list , list_of_int , list_of_str ):
57
49
# product of empty factors
58
50
X = [empty_list , list_of_int , empty_list ]
@@ -70,13 +62,13 @@ def test_empty(self, empty_list, list_of_int, list_of_str):
70
62
expected = []
71
63
assert result == expected
72
64
73
- @settings (max_examples = NO_OF_EXAMPLES_PER_TEST_CASE )
74
- @given (st .integers (),
75
- st .text (string .ascii_letters , min_size = 1 ),
76
- get_seq ((int , str ), True , min_size = 1 ),
77
- st .builds (lambda * x : list (x ), st .integers (),
78
- st .text (string .ascii_letters , min_size = 1 ),
79
- st .lists (st .integers (), min_size = 1 )))
65
+ @hp . settings (max_examples = 20 )
66
+ @hp . given (hp . st .integers (),
67
+ hp . st .text (string .ascii_letters , min_size = 1 ),
68
+ hp . get_seq ((int , str ), True , min_size = 1 ),
69
+ hp . st .builds (lambda * x : list (x ), hp . st .integers (),
70
+ hp . st .text (string .ascii_letters , min_size = 1 ),
71
+ hp . st .lists (hp . st .integers (), min_size = 1 )))
80
72
def test_invalid_input (self , number , text , seq , mixed_seq ):
81
73
82
74
invalid_inputs = [number ,
0 commit comments