Skip to content

Commit

Permalink
Merge pull request #396 from knaaptime/skplt
Browse files Browse the repository at this point in the history
isochrone parallel tests
  • Loading branch information
knaaptime authored Feb 28, 2024
2 parents 4375bae + 0454e8b commit 91eebfd
Showing 1 changed file with 26 additions and 12 deletions.
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)

0 comments on commit 91eebfd

Please sign in to comment.