5
5
import pytest
6
6
7
7
from delphi_quidel import data_tools
8
- from delphi_utils import NAN_CODES
8
+ from delphi_utils import Nans
9
9
10
10
11
11
class TestDataTools :
@@ -99,17 +99,17 @@ def test__geographical_pooling(self, min_obs, max_borrow_obs, expected):
99
99
np .array ([np .nan , 1 / 2 , 1 / 2 , 4 / 10 ]),
100
100
np .array ([np .nan , np .sqrt (0.25 / 4 ), np .sqrt (0.25 / 6 ), np .sqrt (0.24 / 10 )]),
101
101
np .array ([np .nan , 4 , 6 , 10 ]),
102
- np .array ([NAN_CODES [ "Data Insufficient" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ] ]),
103
- np .array ([NAN_CODES [ "Data Insufficient" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ] ]),
104
- np .array ([NAN_CODES [ "Data Insufficient" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ] ])
102
+ np .array ([Nans . DATA_INSUFFICIENT , Nans . NOT_MISSING , Nans . NOT_MISSING , Nans . NOT_MISSING ]),
103
+ np .array ([Nans . DATA_INSUFFICIENT , Nans . NOT_MISSING , Nans . NOT_MISSING , Nans . NOT_MISSING ]),
104
+ np .array ([Nans . DATA_INSUFFICIENT , Nans . NOT_MISSING , Nans . NOT_MISSING , Nans . NOT_MISSING ])
105
105
),
106
106
(1 , # no cases of tests < min_obs
107
107
np .array ([1 / 2 , 2 / 4 , 3 / 6 , 4 / 10 ]),
108
108
np .array ([np .sqrt (0.25 / 2 ), np .sqrt (0.25 / 4 ), np .sqrt (0.25 / 6 ), np .sqrt (0.24 / 10 )]),
109
109
np .array ([2 , 4 , 6 , 10 ]),
110
- np .repeat (NAN_CODES [ "Not Missing" ] , 4 ),
111
- np .repeat (NAN_CODES [ "Not Missing" ] , 4 ),
112
- np .repeat (NAN_CODES [ "Not Missing" ] , 4 ))
110
+ np .repeat (Nans . NOT_MISSING , 4 ),
111
+ np .repeat (Nans . NOT_MISSING , 4 ),
112
+ np .repeat (Nans . NOT_MISSING , 4 ))
113
113
])
114
114
def test_raw_positive_prop (self , min_obs , expected_pos_prop , expected_se , expected_sample_sz , expected_missing_val , expected_missing_se , expected_missing_sample_size ):
115
115
positives = np .array ([1 , 2 , 3 , 4 ])
@@ -145,9 +145,9 @@ def test_raw_positive_prop(self, min_obs, expected_pos_prop, expected_se, expect
145
145
np .array ([np .nan , 1 / 2 , 1 / 2 , 7 / 16 ]),
146
146
np .array ([np .nan , np .sqrt (0.25 / 6 ), np .sqrt (0.25 / 10 ), np .sqrt (63 / 256 / 16 )]),
147
147
np .array ([np .nan , 6 , 10 , 16 ]),
148
- np .array ([NAN_CODES [ "Data Insufficient" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ] ]),
149
- np .array ([NAN_CODES [ "Data Insufficient" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ] ]),
150
- np .array ([NAN_CODES [ "Data Insufficient" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ] ])
148
+ np .array ([Nans . DATA_INSUFFICIENT , Nans . NOT_MISSING , Nans . NOT_MISSING , Nans . NOT_MISSING ]),
149
+ np .array ([Nans . DATA_INSUFFICIENT , Nans . NOT_MISSING , Nans . NOT_MISSING , Nans . NOT_MISSING ]),
150
+ np .array ([Nans . DATA_INSUFFICIENT , Nans . NOT_MISSING , Nans . NOT_MISSING , Nans . NOT_MISSING ])
151
151
),
152
152
(3 , # parents case
153
153
3 ,
@@ -157,9 +157,9 @@ def test_raw_positive_prop(self, min_obs, expected_pos_prop, expected_se, expect
157
157
np .array ([1.6 / 3 , 1 / 2 , 1 / 2 , 7 / 16 ]),
158
158
np .array ([np .sqrt (56 / 225 / 3 ), np .sqrt (0.25 / 6 ), np .sqrt (0.25 / 10 ), np .sqrt (63 / 256 / 16 )]),
159
159
np .array ([3 , 6 , 10 , 16 ]),
160
- np .repeat (NAN_CODES [ "Not Missing" ] , 4 ),
161
- np .repeat (NAN_CODES [ "Not Missing" ] , 4 ),
162
- np .repeat (NAN_CODES [ "Not Missing" ] , 4 )
160
+ np .repeat (Nans . NOT_MISSING , 4 ),
161
+ np .repeat (Nans . NOT_MISSING , 4 ),
162
+ np .repeat (Nans . NOT_MISSING , 4 )
163
163
),
164
164
])
165
165
def test_smoothed_positive_prop (self , min_obs , max_borrow_obs , pool_days , parent_positives ,
@@ -209,16 +209,16 @@ def test_smoothed_positive_prop(self, min_obs, max_borrow_obs, pool_days, parent
209
209
(3 , # one case of tests < min_obs
210
210
np .array ([np .nan , 2 , 1 / 2 , 10 / 4 ]),
211
211
np .array ([np .nan , 4 , 3 , 10 ]),
212
- np .array ([NAN_CODES [ "Data Insufficient" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ] ]),
213
- np .repeat (NAN_CODES [ "Not Applicable" ] , 4 ),
214
- np .array ([NAN_CODES [ "Data Insufficient" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ] ])
212
+ np .array ([Nans . DATA_INSUFFICIENT , Nans . NOT_MISSING , Nans . NOT_MISSING , Nans . NOT_MISSING ]),
213
+ np .repeat (Nans . NOT_APPLICABLE , 4 ),
214
+ np .array ([Nans . DATA_INSUFFICIENT , Nans . NOT_MISSING , Nans . NOT_MISSING , Nans . NOT_MISSING ])
215
215
),
216
216
(1 , # no cases of tests < min_obs
217
217
np .array ([2 , 2 , 1 / 2 , 10 / 4 ]),
218
218
np .array ([2 , 4 , 3 , 10 ]),
219
- np .repeat (NAN_CODES [ "Not Missing" ] , 4 ),
220
- np .repeat (NAN_CODES [ "Not Applicable" ] , 4 ),
221
- np .repeat (NAN_CODES [ "Not Missing" ] , 4 )
219
+ np .repeat (Nans . NOT_MISSING , 4 ),
220
+ np .repeat (Nans . NOT_APPLICABLE , 4 ),
221
+ np .repeat (Nans . NOT_MISSING , 4 )
222
222
),
223
223
])
224
224
def test_raw_tests_per_device (self , min_obs , expected_tests_per_device , expected_sample_sz , expected_missing_val , expected_missing_se , expected_missing_sample_size ):
@@ -252,9 +252,9 @@ def test_raw_tests_per_device(self, min_obs, expected_tests_per_device, expected
252
252
np .array ([np .nan , 2 , 5 / 6 , 8 / 7 ]),
253
253
np .repeat (np .nan , 4 ),
254
254
np .array ([np .nan , 6 , 10 , 16 ]),
255
- np .array ([NAN_CODES [ "Data Insufficient" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ] ]),
256
- np .repeat (NAN_CODES [ "Not Applicable" ] , 4 ),
257
- np .array ([NAN_CODES [ "Data Insufficient" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ], NAN_CODES [ "Not Missing" ] ])
255
+ np .array ([Nans . DATA_INSUFFICIENT , Nans . NOT_MISSING , Nans . NOT_MISSING , Nans . NOT_MISSING ]),
256
+ np .repeat (Nans . NOT_APPLICABLE , 4 ),
257
+ np .array ([Nans . DATA_INSUFFICIENT , Nans . NOT_MISSING , Nans . NOT_MISSING , Nans . NOT_MISSING ])
258
258
),
259
259
(3 , # no parents case
260
260
3 ,
@@ -264,9 +264,9 @@ def test_raw_tests_per_device(self, min_obs, expected_tests_per_device, expected
264
264
np .array ([3 / 1.6 , 2 , 5 / 6 , 8 / 7 ]),
265
265
np .repeat (np .nan , 4 ),
266
266
np .array ([3 , 6 , 10 , 16 ]),
267
- np .repeat (NAN_CODES [ "Not Missing" ] , 4 ),
268
- np .repeat (NAN_CODES [ "Not Applicable" ] , 4 ),
269
- np .repeat (NAN_CODES [ "Not Missing" ] , 4 )
267
+ np .repeat (Nans . NOT_MISSING , 4 ),
268
+ np .repeat (Nans . NOT_APPLICABLE , 4 ),
269
+ np .repeat (Nans . NOT_MISSING , 4 )
270
270
),
271
271
])
272
272
def test_smoothed_tests_per_device (self , min_obs , max_borrow_obs , pool_days , parent_devices ,
0 commit comments