55import pytest
66
77
8+ testdata = [
9+ np .array ([1234 , 1235 , 1236 , 1237 , 1238 , 1239 , 1240 , 1241 , 1242 ]),
10+ np .array ([1 , 2 , 3 , 4 , 5 , 5.5 , 6 , 6.5 , 7 ]),
11+ ]
12+
13+
814@pytest .mark .parametrize ("t, y, to_exclude, poly_features, alpha, expected" , [
915 (
10- np .array ([1234 ,1235 ,1236 ,1237 ,1238 ,1239 ,1240 ,1241 ,1242 ]),
11- np .array ([1 ,2 ,3 ,4 ,5 ,5.5 ,6 ,6.5 ,7 ]),
16+ * testdata ,
1217 2 ,
1318 [1 , 2 ],
1419 0.05 ,
3641 })
3742 ),
3843 (
39- np .array ([1234 ,1235 ,1236 ,1237 ,1238 ,1239 ,1240 ,1241 ,1242 ]),
40- np .array ([1 ,2 ,3 ,4 ,5 ,5.5 ,6 ,6.5 ,7 ]),
44+ * testdata ,
4145 2 ,
4246 [3 ],
4347 0.05 ,
@@ -70,4 +74,68 @@ def test_tolerance_checking_BAU(t, y, to_exclude, poly_features, alpha, expected
7074 assert expected .equals (obtained )
7175
7276
73- #@pytest.mark.parametrize("t, y, to_exclude, poly_features, alpha, forecast", [])
77+ @pytest .mark .parametrize ("t, y, to_exclude, poly_features, alpha" , [
78+ (
79+ * testdata ,
80+ 2 ,
81+ "flamingo" , # This should be a list
82+ 0.05 ,
83+ ),
84+ (
85+ * testdata ,
86+ 2 ,
87+ [2 ],
88+ "flamingo" , # Needs to be int
89+ ),
90+ (
91+ * testdata ,
92+ 2 ,
93+ [2 ],
94+ 42 , # Needs to be between 0 and 1
95+ ),
96+ (
97+ * testdata ,
98+ "flamingo" , # Needs to be int
99+ [2 ],
100+ 0.05 ,
101+ ),
102+ ])
103+ def test_ValueErrors (t , y , to_exclude , poly_features , alpha ):
104+ with pytest .raises (ValueError ):
105+ check_tolerance (t , y , to_exclude = to_exclude ,
106+ poly_features = poly_features , alpha = alpha )
107+
108+
109+ @pytest .mark .parametrize ("t, y, to_exclude, poly_features, alpha" , [
110+ (
111+ * testdata ,
112+ 2 ,
113+ [42 ], # Elements in the list should be between 0 and 4
114+ 0.05 ,
115+ ),
116+ (
117+ * testdata ,
118+ 42 , # Can't have to_exclude making your sample size smaller than 4
119+ [2 ],
120+ 0.05 ,
121+ ),
122+ (
123+ np .array ([1234 , 1235 , 1236 , 1237 , 1238 , 1239 ,
124+ 1240 , 1241 , np .nan ]), # Missing t value
125+ np .array ([1 , 2 , 3 , 4 , 5 , 5.5 , 6 , 6.5 , 7 ]),
126+ 2 ,
127+ [2 ],
128+ 0.05 ,
129+ ),
130+ (
131+ np .array ([1234 , 1235 , 1236 , 1237 , 1238 , 1239 , 1240 , 1241 , 1242 ]),
132+ np .array ([1 , 2 , 3 , 4 , 5 , 5.5 , 6 , 6.5 , np .nan ]), # Missing y value
133+ 2 ,
134+ [2 ],
135+ 0.05 ,
136+ )
137+ ])
138+ def test_AssertionErrors (t , y , to_exclude , poly_features , alpha ):
139+ with pytest .raises (AssertionError ):
140+ check_tolerance (t , y , to_exclude = to_exclude ,
141+ poly_features = poly_features , alpha = alpha )
0 commit comments