@@ -19,48 +19,40 @@ def expected_output():
19
19
end = pd .Timestamp (2019 , 1 , 1 , 23 , 59 , 0 ), freq = '1h' )
20
20
21
21
expected_no_cleaning = pd .Series (
22
- data = [0.884980357535360 , 0.806308930084762 , 0.749974647038078 ,
23
- 0.711804155175089 , 0.687489866078621 , 0.672927554408964 ,
24
- 0.664714899337491 , 0.660345851212099 , 0.658149551658860 ,
25
- 0.657104593968981 , 0.656633344364056 , 0.656431630729954 ,
26
- 0.656349579062171 , 0.656317825078228 , 0.656306121502393 ,
27
- 0.656302009396500 , 0.656300630853678 , 0.656300189543417 ,
28
- 0.656300054532516 , 0.656300015031680 , 0.656300003971846 ,
29
- 0.656300001006533 , 0.656300000244750 , 0.656300000057132 ],
22
+ data = [0.97230454 , 0.95036146 , 0.93039061 , 0.91177978 , 0.89427556 ,
23
+ 0.8777455 , 0.86211038 , 0.84731759 , 0.83332881 , 0.82011354 ,
24
+ 0.80764549 , 0.79590056 , 0.78485556 , 0.77448749 , 0.76477312 ,
25
+ 0.75568883 , 0.74721046 , 0.73931338 , 0.73197253 , 0.72516253 ,
26
+ 0.7188578 , 0.71303268 , 0.7076616 , 0.70271919 ],
30
27
index = dt )
31
-
32
28
return expected_no_cleaning
33
29
34
-
35
30
@pytest .fixture
36
31
def expected_output_1 ():
37
- return np .array ([
38
- 0.99927224 , 0.99869067 , 0.99815393 , 0.99764437 , 1.0 ,
39
- 0.99927224 , 0.99869067 , 0.99815393 , 1.0 , 1.0 ,
40
- 0.99927224 , 0.99869067 , 0.99815393 , 0.99764437 , 0.99715412 ,
41
- 0.99667873 , 0.99621536 , 0.99576203 , 0.99531731 , 0.9948801 ,
42
- 0.99444954 , 0.99402494 , 0.99360572 , 0.99319142 ])
43
-
32
+ dt = pd .date_range (start = pd .Timestamp (2019 , 1 , 1 , 0 , 0 , 0 ),
33
+ end = pd .Timestamp (2019 , 1 , 1 , 23 , 59 , 0 ), freq = '1h' )
34
+ expected_output_1 = pd .Series (
35
+ data = [0.9872406 , 0.97706269 , 0.96769693 , 0.95884032 , 1. ,
36
+ 0.9872406 , 0.97706269 , 0.96769693 , 1. , 1. ,
37
+ 0.9872406 , 0.97706269 , 0.96769693 , 0.95884032 , 0.95036001 ,
38
+ 0.94218263 , 0.93426236 , 0.92656836 , 0.91907873 , 0.91177728 ,
39
+ 0.9046517 , 0.89769238 , 0.89089165 , 0.88424329 ],
40
+ index = dt )
41
+ return expected_output_1
44
42
45
43
@pytest .fixture
46
- def expected_output_2 (expected_output ):
47
- # Sample output (calculated manually)
44
+ def expected_output_2 ():
48
45
dt = pd .date_range (start = pd .Timestamp (2019 , 1 , 1 , 0 , 0 , 0 ),
49
46
end = pd .Timestamp (2019 , 1 , 1 , 23 , 59 , 0 ), freq = '1h' )
47
+ expected_output_2 = pd .Series (
48
+ data = [0.97229869 , 0.95035106 , 0.93037619 , 0.91176175 , 1. ,
49
+ 1. , 1. , 0.97229869 , 1. , 1. ,
50
+ 1. , 1. , 0.97229869 , 0.95035106 , 0.93037619 ,
51
+ 0.91176175 , 0.89425431 , 1. , 1. , 1. ,
52
+ 1. , 0.97229869 , 0.95035106 , 0.93037619 ],
53
+ index = dt )
50
54
51
- expected_no_cleaning = expected_output
52
-
53
- expected = pd .Series (index = dt , dtype = 'float64' )
54
- expected [dt [:4 ]] = expected_no_cleaning [dt [:4 ]]
55
- expected [dt [4 :7 ]] = 1.
56
- expected [dt [7 ]] = expected_no_cleaning [dt [0 ]]
57
- expected [dt [8 :12 ]] = 1.
58
- expected [dt [12 :17 ]] = expected_no_cleaning [dt [:5 ]]
59
- expected [dt [17 :21 ]] = 1.
60
- expected [dt [21 :]] = expected_no_cleaning [:3 ]
61
-
62
- return expected
63
-
55
+ return expected_output_2
64
56
65
57
@pytest .fixture
66
58
def rainfall_input ():
@@ -81,7 +73,7 @@ def test_hsu_no_cleaning(rainfall_input, expected_output):
81
73
rainfall = rainfall_input
82
74
pm2_5 = 1.0
83
75
pm10 = 2.0
84
- depo_veloc = {'2_5' : 1.0 , '10' : 1.0 }
76
+ depo_veloc = {'2_5' : 1.0e-5 , '10' : 1.0e-4 }
85
77
tilt = 0.
86
78
expected_no_cleaning = expected_output
87
79
@@ -99,16 +91,15 @@ def test_hsu(rainfall_input, expected_output_2):
99
91
rainfall = rainfall_input
100
92
pm2_5 = 1.0
101
93
pm10 = 2.0
102
- depo_veloc = {'2_5' : 1.0 , '10' : 1.0 }
94
+ depo_veloc = {'2_5' : 1.0e-4 , '10' : 1.0e-4 }
103
95
tilt = 0.
104
- expected = expected_output_2
105
96
106
97
# three cleaning events at 4:00-6:00, 8:00-11:00, and 17:00-20:00
107
98
result = hsu (rainfall = rainfall , cleaning_threshold = 0.5 , tilt = tilt ,
108
99
pm2_5 = pm2_5 , pm10 = pm10 , depo_veloc = depo_veloc ,
109
100
rain_accum_period = pd .Timedelta ('3h' ))
110
101
111
- assert_series_equal (result , expected )
102
+ assert_series_equal (result , expected_output_2 )
112
103
113
104
114
105
@requires_scipy
@@ -119,8 +110,8 @@ def test_hsu_defaults(rainfall_input, expected_output_1):
119
110
accumulation period.
120
111
"""
121
112
result = hsu (
122
- rainfall = rainfall_input , cleaning_threshold = 0.5 , tilt = 0.0 , pm2_5 = 1.0 ,
123
- pm10 = 2.0 )
113
+ rainfall = rainfall_input , cleaning_threshold = 0.5 , tilt = 0.0 , pm2_5 = 1.0e-2 ,
114
+ pm10 = 2.0e-2 )
124
115
assert np .allclose (result .values , expected_output_1 )
125
116
126
117
0 commit comments