Skip to content

Commit

Permalink
Merge branch 'branch-25.02' into fix-cuproj-doc-example
Browse files Browse the repository at this point in the history
  • Loading branch information
isVoid authored Dec 25, 2024
2 parents ca1aec9 + 768ba50 commit efcfb85
Show file tree
Hide file tree
Showing 12 changed files with 147 additions and 59 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ concurrency:
jobs:
pr-builder:
needs:
- check-nightly-ci
- changed-files
- checks
- conda-cpp-build
Expand All @@ -32,6 +33,18 @@ jobs:
if: always()
with:
needs: ${{ toJSON(needs) }}
check-nightly-ci:
# Switch to ubuntu-latest once it defaults to a version of Ubuntu that
# provides at least Python 3.11 (see
# https://docs.python.org/3/library/datetime.html#datetime.date.fromisoformat)
runs-on: ubuntu-24.04
env:
RAPIDS_GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
steps:
- name: Check if nightly CI is passing
uses: rapidsai/shared-actions/check_nightly_success/dispatch@main
with:
repo: cuspatial
changed-files:
secrets: inherit
uses: rapidsai/shared-workflows/.github/workflows/changed-files.yaml@branch-25.02
Expand Down
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-118_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ dependencies:
- scikit-build-core>=0.10.0
- scikit-image
- shapely
- sphinx<6
- sphinx
- sqlite
- sysroot_linux-64==2.17
name: all_cuda-118_arch-x86_64
2 changes: 1 addition & 1 deletion conda/environments/all_cuda-125_arch-x86_64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ dependencies:
- scikit-build-core>=0.10.0
- scikit-image
- shapely
- sphinx<6
- sphinx
- sqlite
- sysroot_linux-64==2.17
name: all_cuda-125_arch-x86_64
2 changes: 1 addition & 1 deletion cpp/cmake/Modules/ConfigureCUDA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
endif()
endif(CMAKE_COMPILER_IS_GNUCXX)

list(APPEND CUSPATIAL_CUDA_FLAGS --expt-extended-lambda)
list(APPEND CUSPATIAL_CUDA_FLAGS --expt-extended-lambda --expt-relaxed-constexpr)

# set warnings as errors
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.2.0)
Expand Down
2 changes: 1 addition & 1 deletion dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ dependencies:
- numpydoc
# https://github.com/pydata/pydata-sphinx-theme/issues/1539
- pydata-sphinx-theme!=0.14.2
- sphinx<6
- sphinx
notebooks:
common:
- output_types: [conda, requirements, pyproject]
Expand Down
16 changes: 10 additions & 6 deletions python/cuspatial/cuspatial/_lib/distance.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from libcpp.memory cimport make_shared, shared_ptr, unique_ptr
from libcpp.utility cimport move, pair

from cudf._lib.column cimport Column
from cudf._lib.utils cimport columns_from_table_view
from pylibcudf cimport Table as plc_Table
from pylibcudf.libcudf.column.column cimport column
from pylibcudf.libcudf.column.column_view cimport column_view
from pylibcudf.libcudf.table.table_view cimport table_view
Expand Down Expand Up @@ -60,12 +60,16 @@ def directed_hausdorff_distance(
)
)

owner = Column.from_unique_ptr(move(result.first), data_ptr_exposed=True)

return columns_from_table_view(
result.second,
owners=[owner] * result.second.num_columns()
owner_col = Column.from_unique_ptr(
move(result.first), data_ptr_exposed=True
)
cdef plc_Table plc_owner_table = plc_Table(
[owner_col.to_pylibcudf(mode="read")] * result.second.num_columns()
)
cdef plc_Table plc_result_table = plc_Table.from_table_view(
result.second, plc_owner_table
)
return [Column.from_pylibcudf(col) for col in plc_result_table.columns()]


def pairwise_point_distance(
Expand Down
8 changes: 6 additions & 2 deletions python/cuspatial/cuspatial/_lib/linestring_bounding_boxes.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from libcpp.memory cimport unique_ptr
from libcpp.utility cimport move

from cudf._lib.column cimport Column
from cudf._lib.utils cimport columns_from_unique_ptr
from pylibcudf cimport Table as plc_Table
from pylibcudf.libcudf.column.column_view cimport column_view
from pylibcudf.libcudf.table.table cimport table

Expand All @@ -24,4 +24,8 @@ cpdef linestring_bounding_boxes(Column poly_offsets,
result = move(cpp_linestring_bounding_boxes(
c_poly_offsets, c_x, c_y, R
))
return columns_from_unique_ptr(move(result))
cdef plc_Table plc_table = plc_Table.from_libcudf(move(result))
return [
Column.from_pylibcudf(col)
for col in plc_table.columns()
]
11 changes: 9 additions & 2 deletions python/cuspatial/cuspatial/_lib/points_in_range.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from libcpp.memory cimport unique_ptr
from libcpp.utility cimport move

from cudf._lib.column cimport Column
from cudf._lib.utils cimport data_from_unique_ptr
from pylibcudf cimport Table as plc_Table
from pylibcudf.libcudf.column.column_view cimport column_view
from pylibcudf.libcudf.table.table cimport table

Expand Down Expand Up @@ -38,4 +38,11 @@ cpdef points_in_range(
)
)

return data_from_unique_ptr(move(c_result), column_names=["x", "y"])
cdef plc_Table plc_table = plc_Table.from_libcudf(move(c_result))
return (
{
name: Column.from_pylibcudf(col)
for name, col in zip(["x", "y"], plc_table.columns())
},
None
)
8 changes: 6 additions & 2 deletions python/cuspatial/cuspatial/_lib/polygon_bounding_boxes.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from libcpp.memory cimport unique_ptr
from libcpp.utility cimport move

from cudf._lib.column cimport Column
from cudf._lib.utils cimport columns_from_unique_ptr
from pylibcudf cimport Table as plc_Table
from pylibcudf.libcudf.column.column_view cimport column_view
from pylibcudf.libcudf.table.table cimport table

Expand All @@ -25,4 +25,8 @@ cpdef polygon_bounding_boxes(Column poly_offsets,
result = move(cpp_polygon_bounding_boxes(
c_poly_offsets, c_ring_offsets, c_x, c_y
))
return columns_from_unique_ptr(move(result))
cdef plc_Table table_result = plc_Table.from_libcudf(move(result))
return [
Column.from_pylibcudf(col)
for col in table_result.columns()
]
25 changes: 15 additions & 10 deletions python/cuspatial/cuspatial/_lib/quadtree.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ from libcpp.pair cimport pair
from libcpp.utility cimport move

from cudf._lib.column cimport Column
from cudf._lib.utils cimport data_from_unique_ptr
from pylibcudf cimport Table as plc_Table
from pylibcudf.libcudf.column.column cimport column
from pylibcudf.libcudf.column.column_view cimport column_view
from pylibcudf.libcudf.table.table cimport table
Expand All @@ -30,16 +30,21 @@ cpdef quadtree_on_points(Column x, Column y,
result = move(cpp_quadtree_on_points(
c_x, c_y, x_min, x_max, y_min, y_max, scale, max_depth, min_size
))
cdef plc_Table plc_table = plc_Table.from_libcudf(move(result.second))
result_names = [
"key",
"level",
"is_internal_node",
"length",
"offset"
]
return (
Column.from_unique_ptr(move(result.first)),
data_from_unique_ptr(
move(result.second),
column_names=[
"key",
"level",
"is_internal_node",
"length",
"offset"
]
(
{
name: Column.from_pylibcudf(col)
for name, col in zip(result_names, plc_table.columns())
},
None
)
)
78 changes: 56 additions & 22 deletions python/cuspatial/cuspatial/_lib/spatial_join.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from libcpp.memory cimport unique_ptr
from libcpp.utility cimport move

from cudf._lib.column cimport Column
from cudf._lib.utils cimport data_from_unique_ptr, table_view_from_table
from pylibcudf cimport Table as plc_Table
from pylibcudf.libcudf.column.column_view cimport column_view
from pylibcudf.libcudf.table.table cimport table, table_view

Expand All @@ -24,20 +24,30 @@ cpdef join_quadtree_and_bounding_boxes(object quadtree,
double y_max,
double scale,
int8_t max_depth):
cdef table_view c_quadtree = table_view_from_table(
quadtree, ignore_index=True)
cdef table_view c_bounding_boxes = table_view_from_table(
bounding_boxes, ignore_index=True)
cdef plc_Table plc_quadtree = plc_Table(
[col.to_pylibcudf(mode="read") for col in quadtree._columns]
)
cdef table_view c_quadtree = plc_quadtree.view()
cdef plc_Table plc_bounding_boxes = plc_Table(
[col.to_pylibcudf(mode="read") for col in bounding_boxes._columns]
)
cdef table_view c_bounding_boxes = plc_bounding_boxes.view()
cdef unique_ptr[table] result
with nogil:
result = move(cpp_join_quadtree_and_bounding_boxes(
c_quadtree,
c_bounding_boxes,
x_min, x_max, y_min, y_max, scale, max_depth
))
return data_from_unique_ptr(
move(result),
column_names=["bbox_offset", "quad_offset"]
cdef plc_Table plc_table = plc_Table.from_libcudf(move(result))
return (
{
name: Column.from_pylibcudf(col)
for name, col in zip(
["bbox_offset", "quad_offset"], plc_table.columns()
)
},
None
)


Expand All @@ -50,10 +60,14 @@ cpdef quadtree_point_in_polygon(object poly_quad_pairs,
Column ring_offsets,
Column poly_points_x,
Column poly_points_y):
cdef table_view c_poly_quad_pairs = table_view_from_table(
poly_quad_pairs, ignore_index=True)
cdef table_view c_quadtree = table_view_from_table(
quadtree, ignore_index=True)
cdef plc_Table plc_poly_quad_pairs = plc_Table(
[col.to_pylibcudf(mode="read") for col in poly_quad_pairs._columns]
)
cdef table_view c_poly_quad_pairs = plc_poly_quad_pairs.view()
cdef plc_Table plc_quadtree = plc_Table(
[col.to_pylibcudf(mode="read") for col in quadtree._columns]
)
cdef table_view c_quadtree = plc_quadtree.view()
cdef column_view c_point_indices = point_indices.view()
cdef column_view c_points_x = points_x.view()
cdef column_view c_points_y = points_y.view()
Expand All @@ -74,9 +88,15 @@ cpdef quadtree_point_in_polygon(object poly_quad_pairs,
c_poly_points_x,
c_poly_points_y
))
return data_from_unique_ptr(
move(result),
column_names=["polygon_index", "point_index"]
cdef plc_Table plc_table = plc_Table.from_libcudf(move(result))
return (
{
name: Column.from_pylibcudf(col)
for name, col in zip(
["polygon_index", "point_index"], plc_table.columns()
)
},
None
)


Expand All @@ -88,10 +108,17 @@ cpdef quadtree_point_to_nearest_linestring(object linestring_quad_pairs,
Column linestring_offsets,
Column linestring_points_x,
Column linestring_points_y):
cdef table_view c_linestring_quad_pairs = table_view_from_table(
linestring_quad_pairs, ignore_index=True)
cdef table_view c_quadtree = table_view_from_table(
quadtree, ignore_index=True)
cdef plc_Table plc_quad_pairs = plc_Table(
[
col.to_pylibcudf(mode="read")
for col in linestring_quad_pairs._columns
]
)
cdef table_view c_linestring_quad_pairs = plc_quad_pairs.view()
cdef plc_Table plc_quadtree = plc_Table(
[col.to_pylibcudf(mode="read") for col in quadtree._columns]
)
cdef table_view c_quadtree = plc_quadtree.view()
cdef column_view c_point_indices = point_indices.view()
cdef column_view c_points_x = points_x.view()
cdef column_view c_points_y = points_y.view()
Expand All @@ -110,7 +137,14 @@ cpdef quadtree_point_to_nearest_linestring(object linestring_quad_pairs,
c_linestring_points_x,
c_linestring_points_y
))
return data_from_unique_ptr(
move(result),
column_names=["point_index", "linestring_index", "distance"]
cdef plc_Table plc_table = plc_Table.from_libcudf(move(result))
return (
{
name: Column.from_pylibcudf(col)
for name, col in zip(
["point_index", "linestring_index", "distance"],
plc_table.columns()
)
},
None
)
39 changes: 28 additions & 11 deletions python/cuspatial/cuspatial/_lib/trajectory.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ from libcpp.pair cimport pair
from libcpp.utility cimport move

from cudf._lib.column cimport Column
from cudf._lib.utils cimport data_from_unique_ptr
from pylibcudf cimport Table as plc_Table
from pylibcudf.libcudf.column.column cimport column
from pylibcudf.libcudf.column.column_view cimport column_view
from pylibcudf.libcudf.table.table cimport table
Expand All @@ -27,10 +27,17 @@ cpdef derive_trajectories(Column object_id, Column x,
cdef pair[unique_ptr[table], unique_ptr[column]] result
with nogil:
result = move(cpp_derive_trajectories(c_id, c_x, c_y, c_ts))
return data_from_unique_ptr(
move(result.first),
column_names=["object_id", "x", "y", "timestamp"]
), Column.from_unique_ptr(move(result.second))
cdef plc_Table plc_table = plc_Table.from_libcudf(move(result.first))
first_result = (
{
name: Column.from_pylibcudf(col)
for name, col in zip(
["object_id", "x", "y", "timestamp"], plc_table.columns()
)
},
None
)
return first_result, Column.from_unique_ptr(move(result.second))


cpdef trajectory_bounding_boxes(size_type num_trajectories,
Expand All @@ -43,9 +50,15 @@ cpdef trajectory_bounding_boxes(size_type num_trajectories,
result = move(cpp_trajectory_bounding_boxes(
num_trajectories, c_id, c_x, c_y
))
return data_from_unique_ptr(
move(result),
column_names=["x_min", "y_min", "x_max", "y_max"]
cdef plc_Table plc_table = plc_Table.from_libcudf(move(result))
return (
{
name: Column.from_pylibcudf(col)
for name, col in zip(
["x_min", "y_min", "x_max", "y_max"], plc_table.columns()
)
},
None
)


Expand All @@ -61,7 +74,11 @@ cpdef trajectory_distances_and_speeds(size_type num_trajectories,
result = move(cpp_trajectory_distances_and_speeds(
num_trajectories, c_id, c_x, c_y, c_ts
))
return data_from_unique_ptr(
move(result),
column_names=["distance", "speed"]
cdef plc_Table plc_table = plc_Table.from_libcudf(move(result))
return (
{
name: Column.from_pylibcudf(col)
for name, col in zip(["distance", "speed"], plc_table.columns())
},
None
)

0 comments on commit efcfb85

Please sign in to comment.