diff --git a/python/cuspatial/cuspatial/core/binpreds/basic_predicates.py b/python/cuspatial/cuspatial/core/binpreds/basic_predicates.py index 85438fefa..3ea4ed7dd 100644 --- a/python/cuspatial/cuspatial/core/binpreds/basic_predicates.py +++ b/python/cuspatial/cuspatial/core/binpreds/basic_predicates.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, NVIDIA CORPORATION. import cudf @@ -67,7 +67,7 @@ def _basic_intersects_count(lhs, rhs): is_degenerate = _multipoints_is_degenerate(intersections) # If all the points in the intersection are in the rhs if len(is_degenerate) > 0: - sizes[is_degenerate] = 1 + sizes[is_degenerate] = sizes.dtype.type(1) return sizes diff --git a/python/cuspatial/cuspatial/core/binpreds/contains_geometry_processor.py b/python/cuspatial/cuspatial/core/binpreds/contains_geometry_processor.py index fb8af71af..8ff5dd659 100644 --- a/python/cuspatial/cuspatial/core/binpreds/contains_geometry_processor.py +++ b/python/cuspatial/cuspatial/core/binpreds/contains_geometry_processor.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, NVIDIA CORPORATION. import cupy as cp @@ -231,6 +231,7 @@ def _postprocess_multipoint_rhs( return count_result hits = result_df["point_index_x"] hits.index = count_result.iloc[result_df["rhs_index"]].index + count_result = count_result.astype(hits.dtype) count_result.iloc[result_df["rhs_index"]] = hits return count_result diff --git a/python/cuspatial/cuspatial/core/geoseries.py b/python/cuspatial/cuspatial/core/geoseries.py index 64a977ec5..acf472749 100644 --- a/python/cuspatial/cuspatial/core/geoseries.py +++ b/python/cuspatial/cuspatial/core/geoseries.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023, NVIDIA CORPORATION +# Copyright (c) 2020-2024, NVIDIA CORPORATION from functools import cached_property from numbers import Integral @@ -660,15 +660,15 @@ def _align_to_index( index, how, sort, allow_non_unique ) ).astype("int32") - aligned_union_offsets[ - aligned_union_offsets.isna() - ] = Feature_Enum.NONE.value + aligned_union_offsets[aligned_union_offsets.isna()] = np.int32( + Feature_Enum.NONE.value + ) aligned_input_types = self._column._meta.input_types._align_to_index( index, how, sort, allow_non_unique ).astype("int8") - aligned_input_types[ - aligned_input_types.isna() - ] = Feature_Enum.NONE.value + aligned_input_types[aligned_input_types.isna()] = np.int8( + Feature_Enum.NONE.value + ) column = GeoColumn( ( self._column.points, diff --git a/python/cuspatial/cuspatial/tests/test_geodataframe.py b/python/cuspatial/cuspatial/tests/test_geodataframe.py index fe25cc1f9..876e30dc5 100644 --- a/python/cuspatial/cuspatial/tests/test_geodataframe.py +++ b/python/cuspatial/cuspatial/tests/test_geodataframe.py @@ -1,4 +1,6 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. +import sys + import geopandas as gpd import numpy as np import pandas as pd @@ -321,8 +323,9 @@ def test_boolmask(gpdf, df_boolmask): @pytest.mark.xfail( + sys.version_info.major >= 3 and sys.version_info.minor >= 11, reason="Size discrepancies between Python versions. See " - "https://github.com/rapidsai/cuspatial/issues/1352" + "https://github.com/rapidsai/cuspatial/issues/1352", ) def test_memory_usage(gs): assert gs.memory_usage() == 224 diff --git a/python/cuspatial/cuspatial/tests/test_geoseries.py b/python/cuspatial/cuspatial/tests/test_geoseries.py index a865049a8..395b58512 100644 --- a/python/cuspatial/cuspatial/tests/test_geoseries.py +++ b/python/cuspatial/cuspatial/tests/test_geoseries.py @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2021, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. from enum import Enum from numbers import Integral @@ -27,7 +27,7 @@ np.random.seed(0) -class Test_Feature_Enum(Enum): +class Example_Feature_Enum(Enum): POINT = 0 MULTIPOINT = 1 LINESTRING = 2 @@ -54,7 +54,7 @@ def random_multipolygon(size): def generate_random_shapely_feature( - size: Integral, has_z: bool = False, obj_type: Test_Feature_Enum = None + size: Integral, has_z: bool = False, obj_type: Example_Feature_Enum = None ): obj_type = obj_type.value if obj_type else np.random.randint(1, 7) if obj_type == 1: @@ -78,7 +78,7 @@ def generate_random_shapely_feature( return random_multipolygon(size) -def generator(size: Integral, obj_type: Test_Feature_Enum = None): +def generator(size: Integral, obj_type: Example_Feature_Enum = None): geos_list = [] for i in range(size): geo = generate_random_shapely_feature(3, obj_type) @@ -257,7 +257,7 @@ def test_getitem_lines(): def test_getitem_slice_same_index(): - gps = gpd.GeoSeries(generator(3, Test_Feature_Enum.POINT)) + gps = gpd.GeoSeries(generator(3, Example_Feature_Enum.POINT)) cus = cuspatial.from_geopandas(gps) assert_eq_geo(cus[0:1].to_geopandas(), gps[0:1]) assert_eq_geo(cus[0:1].to_geopandas(), gps[0:1]) diff --git a/python/cuspatial/cuspatial/utils/binpred_utils.py b/python/cuspatial/cuspatial/utils/binpred_utils.py index 5a1a0fb0b..c8e2804eb 100644 --- a/python/cuspatial/cuspatial/utils/binpred_utils.py +++ b/python/cuspatial/cuspatial/utils/binpred_utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2023, NVIDIA CORPORATION. +# Copyright (c) 2023-2024, NVIDIA CORPORATION. import cupy as cp import numpy as np @@ -363,7 +363,7 @@ def _points_and_lines_to_multipoints(geoseries, offsets): points = geoseries[points_mask] lines = geoseries[lines_mask] points_offsets = _zero_series(len(geoseries)) - points_offsets[points_mask] = 1 + points_offsets[points_mask] = points_offsets.dtype.type(1) lines_series = geoseries[lines_mask] lines_sizes = lines_series.sizes xy = _zero_series(len(points.points.xy) + len(lines.lines.xy)) @@ -372,9 +372,10 @@ def _points_and_lines_to_multipoints(geoseries, offsets): lines_sizes.index = points_offsets[lines_mask].index points_offsets[lines_mask] = lines_series.sizes.values sizes[lines_mask] = lines.sizes.values * 2 - sizes[points_mask] = 2 + sizes[points_mask] = sizes.dtype.type(2) # TODO Inevitable host device copy points_xy_mask = cp.array(np.repeat(points_mask, sizes.values_host)) + xy = xy.astype(points.points.xy.dtype) xy.iloc[points_xy_mask] = points.points.xy.reset_index(drop=True) xy.iloc[~points_xy_mask] = lines.lines.xy.reset_index(drop=True) collected_offsets = cudf.concat( @@ -446,6 +447,7 @@ def _pli_features_rebuild_offsets(pli, features): # Recompute the offsets for the new series grouped_sizes = in_sizes.groupby(level=0).sum().sort_index() out_sizes = _zero_series(len(pli[0]) - 1) + out_sizes = out_sizes.astype(grouped_sizes.dtype) out_sizes.iloc[grouped_sizes.index] = grouped_sizes offsets = cudf.concat([cudf.Series([0]), out_sizes.cumsum()]) return offsets diff --git a/python/cuspatial/pyproject.toml b/python/cuspatial/pyproject.toml index 8b2055bb7..15b1053be 100644 --- a/python/cuspatial/pyproject.toml +++ b/python/cuspatial/pyproject.toml @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2023, NVIDIA CORPORATION. +# Copyright (c) 2022-2024, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -120,3 +120,9 @@ wheel.packages = ["cuspatial"] provider = "scikit_build_core.metadata.regex" input = "cuspatial/VERSION" regex = "(?P.*)" + +[tool.pytest.ini_options] +xfail_strict = true +filterwarnings = [ + "error:::cudf" +]