diff --git a/geosnap/_data.py b/geosnap/_data.py index ec46d236..4a8e74dd 100644 --- a/geosnap/_data.py +++ b/geosnap/_data.py @@ -230,8 +230,8 @@ def seda( remote_path, converters={"sedasch": str, "fips": str} ) t.sedasch = t.sedasch.str.rjust(12, "0") - except FileNotFoundError: - raise FileNotFoundError( + except FileNotFoundError as e: + raise FileNotFoundError from e( "Unable to access local or remote SEDA data" ) elif level == "geodist": @@ -240,8 +240,8 @@ def seda( remote_path, converters={"sedalea": str, "fips": str} ) t.sedalea = t.sedalea.str.rjust(7, "0") - except FileNotFoundError: - raise FileNotFoundError( + except FileNotFoundError as e: + raise FileNotFoundError from e( "Unable to access local or remote SEDA data" ) t.fips = t.fips.str.rjust(2, "0") @@ -264,10 +264,7 @@ def nces(self, year=1516, dataset="sabs"): geopandas.GeoDataFrame geodataframe of NCES data """ - if dataset == "school_districts": - selector = "districts" - else: - selector = dataset + selector = "districts" if dataset == "school_districts" else dataset local_path = pathlib.Path(self.data_dir, "nces", f"{dataset}_{year}.parquet") remote_path = f"s3://spatial-ucr/nces/{selector}/{dataset}_{year}.parquet" msg = "Streaming data from S3. Use `geosnap.io.store_nces()` to store the data locally for better performance" diff --git a/geosnap/tests/test_constructors.py b/geosnap/tests/test_constructors.py index 6b6077ef..09b1c890 100644 --- a/geosnap/tests/test_constructors.py +++ b/geosnap/tests/test_constructors.py @@ -35,10 +35,13 @@ def test_nces_sabs(): assert sabs.shape == (75128, 15) -def test_acs(): +def test_acs_tract(): acs = io.get_acs(store, fips="11", years=[2018], level="tract") assert acs.shape == (179, 157) +def test_acs_blockgroup(): + acs = io.get_acs(store, fips="11", years=[2018], level="bg") + assert acs.shape == (450, 38) @pytest.mark.skipif(not LTDB, reason="unable to locate LTDB data") def test_ltdb_from_boundary(): diff --git a/geosnap/tests/test_datastore.py b/geosnap/tests/test_datastore.py index b802ed81..ab751fd5 100644 --- a/geosnap/tests/test_datastore.py +++ b/geosnap/tests/test_datastore.py @@ -6,22 +6,18 @@ def test_data_dir(): loc = datasets.show_data_dir() assert len(loc) > 5 - def test_acs(): df = datasets.acs(year=2012, states=["11"]) assert df.shape == (179, 104) - def test_tracts90(): df = datasets.tracts_1990(states=["11"]) assert df.shape == (192, 164) - def test_tracts00(): df = datasets.tracts_2000(states=["11"]) assert df.shape == (188, 192) - def test_tracts10(): df = datasets.tracts_2010(states=["11"]) assert df.shape == (179, 194) @@ -30,25 +26,20 @@ def test_tracts20(): df = datasets.tracts_2020(states=["11"]) assert df.shape == (206, 15) - def test_counties(): assert datasets.counties().shape == (3233, 2) - def test_states(): assert datasets.states().shape == (51, 3) - def test_msas(): df = datasets.msas() assert df.shape == (939, 4) - def test_msa_defs(): df = datasets.msa_definitions() assert df.shape == (1916, 13) - def test_codebook(): df = datasets.codebook() assert df.shape == (194, 12) @@ -68,19 +59,3 @@ def test_blocks_2010(): def test_blocks_2020(): df = datasets.blocks_2020(states=['11']) assert df.shape == (6012, 7) - -def test_ejscreen(): - df = datasets.ejscreen(states=['11'], year=2019) - assert df.shape==(450, 368) - -def test_nces_schools(): - d = datasets.nces(dataset='schools', year='1516') - assert d.shape == (102209, 26) - -def test_nces_districts(): - d = datasets.nces(dataset='school_districts') - assert d.shape == (13352, 18) - -def test_nces_sabs(): - df = datasets.nces(dataset='sabs') - assert df.shape == (75128, 15) \ No newline at end of file