Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

isochrone parallel tests #396

Merged
merged 5 commits into from
Feb 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 26 additions & 12 deletions geosnap/tests/test_isochrones.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,45 @@
isochrones_from_id,
isochrones_from_gdf,
)
from geosnap.io import get_acs
from geosnap import DataStore

import pandana as pdna
import geopandas as gpd
import os
import pytest
import sys
from numpy.testing import assert_almost_equal

if not os.path.exists("./41740.h5"):
import quilt3 as q3

b = q3.Bucket("s3://spatial-ucr")
b.fetch("osm/metro_networks_8k/41740.h5", "./41740.h5")
def get_data():
if not os.path.exists("./41740.h5"):
import quilt3 as q3

datasets = DataStore()
sd_tracts = get_acs(datasets, county_fips="06073", years=[2018])
sd_network = pdna.Network.from_hdf5("41740.h5")
example_origin = 1985327805
b = q3.Bucket("s3://spatial-ucr")
b.fetch("osm/metro_networks_8k/41740.h5", "./41740.h5")
sd_network = pdna.Network.from_hdf5("41740.h5")
example_origin = 1985327805

return example_origin, sd_network


@pytest.mark.skipif(
sys.platform.startswith("win"),
reason="skipping test on windows because of dtype issue",
)
@pytest.mark.xdist_group(name="group1")
def test_isos_from_ids():
example_origin, sd_network = get_data()
iso = isochrones_from_id(example_origin, sd_network, threshold=1600)
assert iso.area.round(6).tolist()[0] == 0.000128
assert_almost_equal(iso.area.round(6).astype(float).tolist()[0], 0.000128)


@pytest.mark.skipif(
sys.platform.startswith("win"),
reason="skipping test on windows because of dtype issue",
)
@pytest.mark.xdist_group(name="group1")
def test_isos_from_gdf():
example_origin, sd_network = get_data()
sd_network.nodes_df["geometry"] = gpd.points_from_xy(
sd_network.nodes_df.x, sd_network.nodes_df.y
)
Expand All @@ -39,4 +53,4 @@ def test_isos_from_gdf():
network=sd_network,
threshold=1600,
)
assert t.area.round(8).tolist()[0] == 0.00012821
assert_almost_equal(t.area.astype(float).round(8).tolist()[0], 0.00012821)
Loading