@@ -28,14 +28,32 @@ def zero(request):
28
28
return request .param
29
29
30
30
31
+ # ------------------------------------------------------------------
32
+ # Vector Fixtures
33
+
31
34
@pytest .fixture (params = [pd .Float64Index (np .arange (5 , dtype = 'float64' )),
32
35
pd .Int64Index (np .arange (5 , dtype = 'int64' )),
33
- pd .UInt64Index (np .arange (5 , dtype = 'uint64' ))],
36
+ pd .UInt64Index (np .arange (5 , dtype = 'uint64' )),
37
+ pd .RangeIndex (5 )],
34
38
ids = lambda x : type (x ).__name__ )
35
- def idx (request ):
39
+ def numeric_idx (request ):
40
+ """
41
+ Several types of numeric-dtypes Index objects
42
+ """
36
43
return request .param
37
44
38
45
46
+ @pytest .fixture
47
+ def tdser ():
48
+ """
49
+ Return a Series with dtype='timedelta64[ns]', including a NaT.
50
+ """
51
+ return pd .Series (['59 Days' , '59 Days' , 'NaT' ], dtype = 'timedelta64[ns]' )
52
+
53
+
54
+ # ------------------------------------------------------------------
55
+ # Scalar Fixtures
56
+
39
57
@pytest .fixture (params = [pd .Timedelta ('5m4s' ).to_pytimedelta (),
40
58
pd .Timedelta ('5m4s' ),
41
59
pd .Timedelta ('5m4s' ).to_timedelta64 ()],
@@ -47,6 +65,72 @@ def scalar_td(request):
47
65
return request .param
48
66
49
67
68
+ @pytest .fixture (params = [pd .offsets .Day (3 ),
69
+ pd .offsets .Hour (72 ),
70
+ pd .Timedelta (days = 3 ).to_pytimedelta (),
71
+ pd .Timedelta ('72:00:00' ),
72
+ np .timedelta64 (3 , 'D' ),
73
+ np .timedelta64 (72 , 'h' )])
74
+ def three_days (request ):
75
+ """
76
+ Several timedelta-like and DateOffset objects that each represent
77
+ a 3-day timedelta
78
+ """
79
+ return request .param
80
+
81
+
82
+ @pytest .fixture (params = [pd .offsets .Hour (2 ),
83
+ pd .offsets .Minute (120 ),
84
+ pd .Timedelta (hours = 2 ).to_pytimedelta (),
85
+ pd .Timedelta (seconds = 2 * 3600 ),
86
+ np .timedelta64 (2 , 'h' ),
87
+ np .timedelta64 (120 , 'm' )])
88
+ def two_hours (request ):
89
+ """
90
+ Several timedelta-like and DateOffset objects that each represent
91
+ a 2-hour timedelta
92
+ """
93
+ return request .param
94
+
95
+
96
+ _common_mismatch = [pd .offsets .YearBegin (2 ),
97
+ pd .offsets .MonthBegin (1 ),
98
+ pd .offsets .Minute ()]
99
+
100
+
101
+ @pytest .fixture (params = [pd .Timedelta (minutes = 30 ).to_pytimedelta (),
102
+ np .timedelta64 (30 , 's' ),
103
+ pd .Timedelta (seconds = 30 )] + _common_mismatch )
104
+ def not_hourly (request ):
105
+ """
106
+ Several timedelta-like and DateOffset instances that are _not_
107
+ compatible with Hourly frequencies.
108
+ """
109
+ return request .param
110
+
111
+
112
+ @pytest .fixture (params = [np .timedelta64 (4 , 'h' ),
113
+ pd .Timedelta (hours = 23 ).to_pytimedelta (),
114
+ pd .Timedelta ('23:00:00' )] + _common_mismatch )
115
+ def not_daily (request ):
116
+ """
117
+ Several timedelta-like and DateOffset instances that are _not_
118
+ compatible with Daily frequencies.
119
+ """
120
+ return request .param
121
+
122
+
123
+ @pytest .fixture (params = [np .timedelta64 (365 , 'D' ),
124
+ pd .Timedelta (days = 365 ).to_pytimedelta (),
125
+ pd .Timedelta (days = 365 )] + _common_mismatch )
126
+ def mismatched_freq (request ):
127
+ """
128
+ Several timedelta-like and DateOffset instances that are _not_
129
+ compatible with Monthly or Annual frequencies.
130
+ """
131
+ return request .param
132
+
133
+
50
134
# ------------------------------------------------------------------
51
135
52
136
@pytest .fixture (params = [pd .Index , pd .Series , pd .DataFrame ],
@@ -59,6 +143,18 @@ def box(request):
59
143
return request .param
60
144
61
145
146
+ @pytest .fixture (params = [pd .Index ,
147
+ pd .Series ,
148
+ pytest .param (pd .DataFrame ,
149
+ marks = pytest .mark .xfail (strict = True ))],
150
+ ids = lambda x : x .__name__ )
151
+ def box_df_fail (request ):
152
+ """
153
+ Fixture equivalent to `box` fixture but xfailing the DataFrame case.
154
+ """
155
+ return request .param
156
+
157
+
62
158
@pytest .fixture (params = [
63
159
pd .Index ,
64
160
pd .Series ,
0 commit comments