diff --git a/python/cuspatial/benchmarks/api/bench_api.py b/python/cuspatial/benchmarks/api/bench_api.py index d93e45ebb..d8e24cf33 100644 --- a/python/cuspatial/benchmarks/api/bench_api.py +++ b/python/cuspatial/benchmarks/api/bench_api.py @@ -1,4 +1,6 @@ -# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Copyright (c) 2022-2024, NVIDIA CORPORATION. +import pathlib + import cupy import geopandas import pytest @@ -223,12 +225,16 @@ def bench_quadtree_point_to_nearest_linestring(benchmark): SCALE = 3 MAX_DEPTH = 7 MIN_SIZE = 125 - host_countries = geopandas.read_file( - geopandas.datasets.get_path("naturalearth_lowres") - ) - host_cities = geopandas.read_file( - geopandas.datasets.get_path("naturalearth_cities") + data_dir = ( + pathlib.Path(__file__).parent.parent.parent + / "cuspatial" + / "tests" + / "data" ) + naturalearth_lowres = data_dir / "naturalearth_lowres.shp" + naturalearth_cities = data_dir / "naturalearth_cities.shp" + host_countries = geopandas.read_file(naturalearth_lowres) + host_cities = geopandas.read_file(naturalearth_cities) gpu_countries = cuspatial.from_geopandas( host_countries[host_countries["geometry"].type == "Polygon"] ) diff --git a/python/cuspatial/cuspatial/tests/conftest.py b/python/cuspatial/cuspatial/tests/conftest.py index 7b6ae2d1b..caa53dcea 100644 --- a/python/cuspatial/cuspatial/tests/conftest.py +++ b/python/cuspatial/cuspatial/tests/conftest.py @@ -1,4 +1,5 @@ -# Copyright (c) 2020-2023, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. +import pathlib import geopandas as gpd import numpy as np @@ -308,13 +309,18 @@ def factory(length): @pytest.fixture -def naturalearth_cities(): - return gpd.read_file(gpd.datasets.get_path("naturalearth_cities")) +def data_dir(): + return pathlib.Path(__file__).parent / "data" @pytest.fixture -def naturalearth_lowres(): - return gpd.read_file(gpd.datasets.get_path("naturalearth_lowres")) +def naturalearth_cities(data_dir): + return gpd.read_file(data_dir / "naturalearth_cities.shp") + + +@pytest.fixture +def naturalearth_lowres(data_dir): + return gpd.read_file(data_dir / "naturalearth_lowres.shp") @pytest.fixture(scope="session") diff --git a/python/cuspatial/cuspatial/tests/data/naturalearth_cities.shp b/python/cuspatial/cuspatial/tests/data/naturalearth_cities.shp new file mode 100644 index 000000000..a7bcefa0a Binary files /dev/null and b/python/cuspatial/cuspatial/tests/data/naturalearth_cities.shp differ diff --git a/python/cuspatial/cuspatial/tests/data/naturalearth_cities.shx b/python/cuspatial/cuspatial/tests/data/naturalearth_cities.shx new file mode 100644 index 000000000..ce83da735 Binary files /dev/null and b/python/cuspatial/cuspatial/tests/data/naturalearth_cities.shx differ diff --git a/python/cuspatial/cuspatial/tests/data/naturalearth_lowres.shp b/python/cuspatial/cuspatial/tests/data/naturalearth_lowres.shp new file mode 100644 index 000000000..5a3440b25 Binary files /dev/null and b/python/cuspatial/cuspatial/tests/data/naturalearth_lowres.shp differ diff --git a/python/cuspatial/cuspatial/tests/data/naturalearth_lowres.shx b/python/cuspatial/cuspatial/tests/data/naturalearth_lowres.shx new file mode 100644 index 000000000..275512f80 Binary files /dev/null and b/python/cuspatial/cuspatial/tests/data/naturalearth_lowres.shx differ diff --git a/python/cuspatial/cuspatial/tests/test_geocolumn_accessor.py b/python/cuspatial/cuspatial/tests/test_geocolumn_accessor.py index db074ae88..c4ec694b6 100644 --- a/python/cuspatial/cuspatial/tests/test_geocolumn_accessor.py +++ b/python/cuspatial/cuspatial/tests/test_geocolumn_accessor.py @@ -1,4 +1,4 @@ -# Copyright 2022 NVIDIA Corporation +# Copyright (c) 2022-2024, NVIDIA CORPORATION import cupy as cp import geopandas as gpd @@ -18,10 +18,10 @@ "range, expected", [[slice(0, 3), [0, 3, 4, 5]], [slice(3, 6), [0, 30, 40, 41]]], ) -def test_GeoColumnAccessor_polygon_offset(range, expected): - gpdf = cuspatial.from_geopandas( - gpd.read_file(gpd.datasets.get_path("naturalearth_lowres")) - ) +def test_GeoColumnAccessor_polygon_offset( + range, expected, naturalearth_lowres +): + gpdf = cuspatial.from_geopandas(naturalearth_lowres) shorter = gpdf[range]["geometry"] expected = cp.array(expected) got = shorter.polygons.geometry_offset diff --git a/python/cuspatial/cuspatial/tests/test_geodataframe.py b/python/cuspatial/cuspatial/tests/test_geodataframe.py index 876e30dc5..718046c17 100644 --- a/python/cuspatial/cuspatial/tests/test_geodataframe.py +++ b/python/cuspatial/cuspatial/tests/test_geodataframe.py @@ -189,10 +189,9 @@ def test_interleaved_polygons(gpdf, polys): ) -def test_to_geopandas_with_geopandas_dataset(): - df = gpd.read_file(gpd.datasets.get_path("naturalearth_lowres")) - gdf = cuspatial.from_geopandas(df) - assert_eq_geo_df(df, gdf.to_geopandas()) +def test_to_geopandas_with_geopandas_dataset(naturalearth_lowres): + gdf = cuspatial.from_geopandas(naturalearth_lowres) + assert_eq_geo_df(naturalearth_lowres, gdf.to_geopandas()) def test_to_shapely_random(): @@ -327,14 +326,12 @@ def test_boolmask(gpdf, df_boolmask): reason="Size discrepancies between Python versions. See " "https://github.com/rapidsai/cuspatial/issues/1352", ) -def test_memory_usage(gs): +def test_memory_usage(gs, data_dir): assert gs.memory_usage() == 224 - host_dataframe = gpd.read_file( - gpd.datasets.get_path("naturalearth_lowres") - ) + host_dataframe = gpd.read_file(data_dir / "naturalearth_lowres.shp") gpu_dataframe = cuspatial.from_geopandas(host_dataframe) # The df size is 8kb of cudf rows and 217kb of the geometry column - assert gpu_dataframe.memory_usage().sum() == 224945 + assert gpu_dataframe.memory_usage().sum() == 216793 def test_from_dict(): diff --git a/python/cuspatial/cuspatial/tests/test_geoseries.py b/python/cuspatial/cuspatial/tests/test_geoseries.py index 395b58512..6e97d037b 100644 --- a/python/cuspatial/cuspatial/tests/test_geoseries.py +++ b/python/cuspatial/cuspatial/tests/test_geoseries.py @@ -551,11 +551,8 @@ def test_memory_usage_simple(gs): assert cugs.memory_usage() == 1616 -def test_memory_usage_large(): - host_dataframe = gpd.read_file( - gpd.datasets.get_path("naturalearth_lowres") - ) - geometry = cuspatial.from_geopandas(host_dataframe)["geometry"] +def test_memory_usage_large(naturalearth_lowres): + geometry = cuspatial.from_geopandas(naturalearth_lowres)["geometry"] # the geometry column from naturalearth_lowres is 217kb of coordinates assert geometry.memory_usage() == 216793 diff --git a/python/cuspatial/pyproject.toml b/python/cuspatial/pyproject.toml index f7a198903..b4ae45e9e 100644 --- a/python/cuspatial/pyproject.toml +++ b/python/cuspatial/pyproject.toml @@ -124,5 +124,9 @@ regex = "(?P.*)" [tool.pytest.ini_options] xfail_strict = true filterwarnings = [ - "error:::cudf" + "error:::cudf", + "error::FutureWarning", + "error::DeprecationWarning", + # https://github.com/pytest-dev/pytest-cov/issues/557 + "ignore:The --rsyncdir command line argument:DeprecationWarning", ]