@@ -168,48 +168,6 @@ def test_load_zip_hrr_table(self):
168
168
assert pd .api .types .is_string_dtype (zip_data ["zip" ])
169
169
assert pd .api .types .is_string_dtype (zip_data ["hrr" ])
170
170
171
- def test_convert_fips_to_state_code (self ):
172
- gmpr = GeoMapper ()
173
- new_data = gmpr .convert_fips_to_state_code (self .fips_data )
174
- assert new_data ["state_code" ].dtype == "O"
175
- assert new_data .loc [1 , "state_code" ] == new_data .loc [1 , "fips" ][:2 ]
176
-
177
- def test_fips_to_state_code (self ):
178
- gmpr = GeoMapper ()
179
- new_data = gmpr .fips_to_state_code (self .fips_data_3 )
180
- assert np .allclose (new_data ["count" ].sum (), self .fips_data_3 ["count" ].sum ())
181
-
182
- def test_convert_state_code_to_state_id (self ):
183
- gmpr = GeoMapper ()
184
- new_data = gmpr .convert_fips_to_state_code (self .fips_data )
185
- new_data = gmpr .convert_state_code_to_state_id (new_data )
186
- assert new_data ["state_id" ].isnull ()[2 ]
187
- assert new_data ["state_id" ][3 ] == "in"
188
- assert len (pd .unique (new_data ["state_id" ])) == 4
189
-
190
- def test_fips_to_state_id (self ):
191
- gmpr = GeoMapper ()
192
- new_data = gmpr .fips_to_state_id (self .fips_data_2 )
193
- assert new_data ["state_id" ][2 ] == "in"
194
- assert new_data .shape [0 ] == 3
195
- assert new_data ["count" ].sum () == self .fips_data_2 ["count" ].sum ()
196
-
197
- def test_fips_to_msa (self ):
198
- gmpr = GeoMapper ()
199
- new_data = gmpr .fips_to_msa (self .fips_data_3 )
200
- assert new_data .shape [0 ] == 2
201
- assert new_data ["msa" ][0 ] == "10180"
202
- new_data = gmpr .fips_to_msa (self .fips_data_3 , create_mega = True )
203
- assert new_data [["count" ]].sum ()[0 ] == self .fips_data_3 ["count" ].sum ()
204
-
205
- def test_zip_to_fips (self ):
206
- gmpr = GeoMapper ()
207
- new_data = gmpr .zip_to_fips (self .zip_data )
208
- assert new_data .shape [0 ] == 10
209
- assert (
210
- new_data [["count" , "total" ]].sum () - self .zip_data [["count" , "total" ]].sum ()
211
- ).sum () < 1e-3
212
-
213
171
def test_megacounty (self ):
214
172
gmpr = GeoMapper ()
215
173
new_data = gmpr .fips_to_megacounty (self .mega_data , 6 , 50 )
@@ -228,53 +186,6 @@ def test_megacounty(self):
228
186
new_data [["count" ]].sum () - self .mega_data [["count" ]].sum ()
229
187
).sum () < 1e-3
230
188
231
- def test_zip_to_hrr (self ):
232
- gmpr = GeoMapper ()
233
- new_data = gmpr .zip_to_hrr (self .zip_data )
234
- assert len (pd .unique (new_data ["hrr" ])) == 2
235
- assert np .allclose (
236
- new_data [["count" , "total" ]].sum (), self .zip_data [["count" , "total" ]].sum ()
237
- )
238
-
239
- def test_jhu_uid_to_fips (self ):
240
- gmpr = GeoMapper ()
241
- new_data = gmpr .jhu_uid_to_fips (self .jhu_uid_data )
242
- assert not (new_data ["fips" ].astype (int ) > 90000 ).any ()
243
- assert new_data ["total" ].sum () == self .jhu_uid_data ["total" ].sum ()
244
-
245
- def test_fips_to_zip (self ):
246
- gmpr = GeoMapper ()
247
- new_data = gmpr .fips_to_zip (self .fips_data_4 )
248
- assert new_data ["count" ].sum () == self .fips_data_4 ["count" ].sum ()
249
-
250
- def test_fips_to_hrr (self ):
251
- gmpr = GeoMapper ()
252
- data = gmpr .convert_fips_to_hrr (self .fips_data_3 )
253
- ind = self .fips_data_3 ["fips" ].isin (data ["fips" ])
254
- data = self .fips_data_3 [ind ]
255
- new_data = gmpr .fips_to_hrr (self .fips_data_3 )
256
- assert new_data .shape == (2 , 4 )
257
- assert new_data ["count" ].sum () == data ["count" ].sum ()
258
-
259
- def test_zip_to_msa (self ):
260
- gmpr = GeoMapper ()
261
- new_data = gmpr .zip_to_msa (self .zip_data )
262
- assert new_data ["msa" ][2 ] == "46700"
263
- assert new_data .shape [0 ] == 6
264
- assert np .allclose (new_data ["count" ].sum (), self .zip_data ["count" ].sum ())
265
-
266
- def test_zip_to_state_code (self ):
267
- gmpr = GeoMapper ()
268
- new_data = gmpr .zip_to_state_code (self .zip_data )
269
- assert new_data .shape [0 ] == 4
270
- assert np .allclose (new_data ["count" ].sum (), self .zip_data ["count" ].sum ())
271
-
272
- def test_zip_to_state_id (self ):
273
- gmpr = GeoMapper ()
274
- new_data = gmpr .zip_to_state_id (self .zip_data )
275
- assert new_data .shape [0 ] == 4
276
- assert np .allclose (new_data ["count" ].sum (), self .zip_data ["count" ].sum ())
277
-
278
189
def test_add_population_column (self ):
279
190
gmpr = GeoMapper ()
280
191
new_data = gmpr .add_population_column (self .fips_data_3 , "fips" )
@@ -289,96 +200,6 @@ def test_add_population_column(self):
289
200
def test_add_geocode (self ):
290
201
gmpr = GeoMapper ()
291
202
292
- # fips -> zip
293
- new_data = gmpr .fips_to_zip (self .fips_data_3 )
294
- new_data2 = gmpr .replace_geocode (self .fips_data_3 , "fips" , "zip" )
295
- assert new_data .equals (new_data2 )
296
-
297
- # fips -> hrr
298
- new_data = gmpr .fips_to_hrr (self .fips_data_3 )
299
- new_data2 = gmpr .replace_geocode (self .fips_data_3 , "fips" , "hrr" )
300
- new_data2 = new_data2 [new_data .columns ]
301
- assert np .allclose (
302
- new_data [["count" , "total" ]].values , new_data2 [["count" , "total" ]].values
303
- )
304
-
305
- # fips -> msa
306
- new_data = gmpr .fips_to_msa (self .fips_data_3 )
307
- new_data2 = gmpr .replace_geocode (self .fips_data_3 , "fips" , "msa" )
308
- new_data2 = new_data2 [new_data .columns ]
309
- assert np .allclose (
310
- new_data [["count" , "total" ]].values , new_data2 [["count" , "total" ]].values
311
- )
312
-
313
- # fips -> state_id
314
- new_data = gmpr .fips_to_state_id (self .fips_data_4 )
315
- new_data2 = gmpr .replace_geocode (self .fips_data_4 , "fips" , "state_id" )
316
- new_data2 = new_data2 [new_data .columns ]
317
- assert np .allclose (
318
- new_data [["count" , "total" ]].values , new_data2 [["count" , "total" ]].values
319
- )
320
-
321
- # fips -> state_code
322
- new_data = gmpr .fips_to_state_code (self .fips_data_4 )
323
- new_data2 = gmpr .replace_geocode (self .fips_data_4 , "fips" , "state_code" )
324
- new_data2 = new_data2 [new_data .columns ]
325
- assert np .allclose (
326
- new_data [["count" , "total" ]].values , new_data2 [["count" , "total" ]].values
327
- )
328
-
329
- # fips -> state_code (again, mostly to cover the test case of when fips
330
- # codes aren't all strings)
331
- new_data = gmpr .fips_to_state_code (self .fips_data_5 )
332
- new_data2 = gmpr .replace_geocode (self .fips_data_5 , "fips" , "state_code" )
333
- new_data2 = new_data2 [new_data .columns ]
334
- assert np .allclose (
335
- new_data [["count" , "total" ]].values , new_data2 [["count" , "total" ]].values
336
- )
337
-
338
- # zip -> fips
339
- new_data = gmpr .zip_to_fips (self .zip_data )
340
- new_data2 = gmpr .replace_geocode (self .zip_data , "zip" , "fips" )
341
- new_data2 = new_data2 [new_data .columns ]
342
- assert new_data .equals (new_data2 )
343
-
344
- # zip -> hrr
345
- new_data = gmpr .zip_to_hrr (self .zip_data )
346
- new_data2 = gmpr .replace_geocode (self .zip_data , "zip" , "hrr" )
347
- new_data2 = new_data2 [new_data .columns ]
348
- assert new_data .equals (new_data2 )
349
-
350
- # zip -> msa
351
- new_data = gmpr .zip_to_msa (self .zip_data )
352
- new_data2 = gmpr .replace_geocode (self .zip_data , "zip" , "msa" )
353
- new_data2 = new_data2 [new_data .columns ]
354
- assert np .allclose (
355
- new_data [["count" , "total" ]].values , new_data2 [["count" , "total" ]].values
356
- )
357
-
358
- # zip -> state_id
359
- new_data = gmpr .zip_to_state_id (self .zip_data )
360
- new_data2 = gmpr .replace_geocode (self .zip_data , "zip" , "state_id" )
361
- new_data2 = new_data2 [new_data .columns ]
362
- assert np .allclose (
363
- new_data [["count" , "total" ]].values , new_data2 [["count" , "total" ]].values
364
- )
365
-
366
- # zip -> state_code
367
- new_data = gmpr .zip_to_state_code (self .zip_data )
368
- new_data2 = gmpr .replace_geocode (self .zip_data , "zip" , "state_code" )
369
- new_data2 = new_data2 [new_data .columns ]
370
- assert np .allclose (
371
- new_data [["count" , "total" ]].values , new_data2 [["count" , "total" ]].values
372
- )
373
-
374
- # jhu_uid -> fips
375
- new_data = gmpr .jhu_uid_to_fips (self .jhu_uid_data )
376
- new_data2 = gmpr .replace_geocode (self .jhu_uid_data , "jhu_uid" , "fips" )
377
- new_data2 = new_data2 [new_data .columns ]
378
- assert np .allclose (
379
- new_data [["count" , "total" ]].values , new_data2 [["count" , "total" ]].values
380
- )
381
-
382
203
# state_code -> hhs
383
204
new_data = gmpr .add_geocode (self .zip_data , "zip" , "state_code" )
384
205
new_data2 = gmpr .add_geocode (new_data , "state_code" , "hhs_region_number" )
0 commit comments