1+ from codonPython .tolerance import check_tolerance
2+ import numpy as np
3+ import pandas as pd
4+ # import pandas.util.testing as pdt
5+ import pytest
6+
7+
8+ @pytest .mark .parametrize ("t, y, to_exclude, poly_features, alpha, forecast, expected" , [
9+ (
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 ]),
12+ 2 ,
13+ [1 , 2 ],
14+ 0.05 ,
15+ False ,
16+ pd .DataFrame ({
17+ 'yhat_u' : [
18+ 8.11380197739608 ,
19+ 9.051653693670929 ,
20+ 7.127135023632205 ,
21+ 7.735627110021585 ,
22+ ],
23+ 'yobs' : [6.5 , 7.0 , 6.5 , 7.0 ],
24+ 'yhat' : [
25+ 7.214285714285714 ,
26+ 8.071428571428573 ,
27+ 6.500000000000002 ,
28+ 6.821428571428574 ,
29+ ],
30+ 'yhat_l' : [
31+ 6.31476945117535 ,
32+ 7.091203449186216 ,
33+ 5.872864976367799 ,
34+ 5.907230032835563 ,
35+ ],
36+ 'polynomial' : [1 , 1 , 2 , 2 ]
37+ })
38+ ),
39+ (
40+ np .array ([1234 ,1235 ,1236 ,1237 ,1238 ,1239 ,1240 ,1241 ,1242 ]),
41+ np .array ([1 ,2 ,3 ,4 ,5 ,5.5 ,6 ,6.5 ,7 ]),
42+ 2 ,
43+ [3 ],
44+ 0.05 ,
45+ True ,
46+ pd .DataFrame ({
47+ 'yhat_u' : [
48+ 6.753927165005773 ,
49+ 7.214574732953706 ,
50+ 7.218216279340497 ,
51+ 7.3980478897523225 ,
52+ 7.575355558900247 ,
53+ 7.750571186675458 ,
54+ 7.924372393971117
55+ ],
56+ 'yobs' : [6.5 , 7.0 , np .nan , np .nan , np .nan , np .nan , np .nan ],
57+ 'yhat' : [
58+ 6.0000000000000036 ,
59+ 5.571428571428576 ,
60+ 5.5659511039999785 ,
61+ 5.249235468428623 ,
62+ 4.842301211809431 ,
63+ 4.339894601476199 ,
64+ 3.7367619047620617
65+ ],
66+ 'yhat_l' : [
67+ 5.2460728349942345 ,
68+ 3.928282409903445 ,
69+ 3.9136859286594596 ,
70+ 3.100423047104923 ,
71+ 2.1092468647186156 ,
72+ 0.929218016276939 ,
73+ - 0.45084858444699405
74+ ],
75+ 'polynomial' : [3 , 3 , 3 , 3 , 3 , 3 , 3 ]
76+ })
77+ ),
78+ ])
79+ def test_tolerance_checking_BAU (t , y , to_exclude , poly_features , alpha , forecast , expected ):
80+ obtained = check_tolerance (
81+ t ,
82+ y ,
83+ to_exclude = to_exclude ,
84+ poly_features = poly_features ,
85+ alpha = alpha ,
86+ forecast = forecast ,
87+ )
88+ assert expected .equals (obtained )
89+
90+
91+ #@pytest.mark.parametrize("t, y, to_exclude, poly_features, alpha, forecast", [])
0 commit comments