diff --git a/python/cuspatial/cuspatial/_lib/interpolate.pyx b/python/cuspatial/cuspatial/_lib/interpolate.pyx index 78d4dd67d..76fbaf8e8 100644 --- a/python/cuspatial/cuspatial/_lib/interpolate.pyx +++ b/python/cuspatial/cuspatial/_lib/interpolate.pyx @@ -5,6 +5,7 @@ from libcpp.utility cimport move from cudf._lib.column cimport Column, column from cudf._lib.table cimport Table, table +from cudf._lib.utils cimport data_from_unique_ptr from cuspatial._lib.cpp.interpolate cimport ( cubicspline_coefficients as cpp_cubicspline_coefficients, @@ -32,8 +33,7 @@ cpdef cubicspline_coefficients( prefixes_v ) ) - result = Table.from_unique_ptr(move(c_result), ["d3", "d2", "d1", "d0"]) - return result + return data_from_unique_ptr(move(c_result), ["d3", "d2", "d1", "d0"]) cpdef cubicspline_interpolate( Column points, diff --git a/python/cuspatial/cuspatial/_lib/polygon_bounding_boxes.pyx b/python/cuspatial/cuspatial/_lib/polygon_bounding_boxes.pyx index 0fbee2dd4..9c7e13f0f 100644 --- a/python/cuspatial/cuspatial/_lib/polygon_bounding_boxes.pyx +++ b/python/cuspatial/cuspatial/_lib/polygon_bounding_boxes.pyx @@ -9,7 +9,7 @@ from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.types cimport size_type -from cudf._lib.table cimport Table +from cudf._lib.utils cimport data_from_unique_ptr from cuspatial._lib.cpp.polygon_bounding_box cimport ( polygon_bounding_boxes as cpp_polygon_bounding_boxes, @@ -28,7 +28,7 @@ cpdef polygon_bounding_boxes(Column poly_offsets, result = move(cpp_polygon_bounding_boxes( c_poly_offsets, c_ring_offsets, c_x, c_y )) - return Table.from_unique_ptr( + return data_from_unique_ptr( move(result), column_names=["x_min", "y_min", "x_max", "y_max"] ) diff --git a/python/cuspatial/cuspatial/_lib/polyline_bounding_boxes.pyx b/python/cuspatial/cuspatial/_lib/polyline_bounding_boxes.pyx index dea49a354..28d06ca58 100644 --- a/python/cuspatial/cuspatial/_lib/polyline_bounding_boxes.pyx +++ b/python/cuspatial/cuspatial/_lib/polyline_bounding_boxes.pyx @@ -9,7 +9,7 @@ from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.types cimport size_type -from cudf._lib.table cimport Table +from cudf._lib.utils cimport data_from_unique_ptr from cuspatial._lib.cpp.polyline_bounding_box cimport ( polyline_bounding_boxes as cpp_polyline_bounding_boxes, @@ -27,7 +27,7 @@ cpdef polyline_bounding_boxes(Column poly_offsets, result = move(cpp_polyline_bounding_boxes( c_poly_offsets, c_x, c_y, R )) - return Table.from_unique_ptr( + return data_from_unique_ptr( move(result), column_names=["x_min", "y_min", "x_max", "y_max"] ) diff --git a/python/cuspatial/cuspatial/_lib/quadtree.pyx b/python/cuspatial/cuspatial/_lib/quadtree.pyx index 51d89057e..598a3c55a 100644 --- a/python/cuspatial/cuspatial/_lib/quadtree.pyx +++ b/python/cuspatial/cuspatial/_lib/quadtree.pyx @@ -10,7 +10,7 @@ from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.types cimport size_type -from cudf._lib.table cimport Table +from cudf._lib.utils cimport data_from_unique_ptr from cuspatial._lib.cpp.quadtree cimport ( quadtree_on_points as cpp_quadtree_on_points, @@ -32,7 +32,7 @@ cpdef quadtree_on_points(Column x, Column y, )) return ( Column.from_unique_ptr(move(result.first)), - Table.from_unique_ptr( + data_from_unique_ptr( move(result.second), column_names=["key", "level", "is_quad", "length", "offset"] ) diff --git a/python/cuspatial/cuspatial/_lib/spatial_join.pyx b/python/cuspatial/cuspatial/_lib/spatial_join.pyx index ec88ae5e2..642ac4c34 100644 --- a/python/cuspatial/cuspatial/_lib/spatial_join.pyx +++ b/python/cuspatial/cuspatial/_lib/spatial_join.pyx @@ -8,6 +8,7 @@ from libcpp.utility cimport move from cudf._lib.column cimport Column, column, column_view from cudf._lib.cpp.types cimport size_type from cudf._lib.table cimport Table, table, table_view +from cudf._lib.utils cimport data_from_unique_ptr from cuspatial._lib.cpp.spatial_join cimport ( join_quadtree_and_bounding_boxes as cpp_join_quadtree_and_bounding_boxes, @@ -33,7 +34,7 @@ cpdef join_quadtree_and_bounding_boxes(Table quadtree, c_poly_bounding_boxes, x_min, x_max, y_min, y_max, scale, max_depth )) - return Table.from_unique_ptr( + return data_from_unique_ptr( move(result), column_names=["poly_offset", "quad_offset"] ) @@ -70,7 +71,7 @@ cpdef quadtree_point_in_polygon(Table poly_quad_pairs, c_poly_points_x, c_poly_points_y )) - return Table.from_unique_ptr( + return data_from_unique_ptr( move(result), column_names=["polygon_index", "point_index"] ) @@ -104,7 +105,7 @@ cpdef quadtree_point_to_nearest_polyline(Table poly_quad_pairs, c_poly_points_x, c_poly_points_y )) - return Table.from_unique_ptr( + return data_from_unique_ptr( move(result), column_names=["point_index", "polyline_index", "distance"] ) diff --git a/python/cuspatial/cuspatial/_lib/spatial_window.pyx b/python/cuspatial/cuspatial/_lib/spatial_window.pyx index b4d67df85..46d3178de 100644 --- a/python/cuspatial/cuspatial/_lib/spatial_window.pyx +++ b/python/cuspatial/cuspatial/_lib/spatial_window.pyx @@ -4,7 +4,8 @@ from libcpp.memory cimport unique_ptr from libcpp.utility cimport move from cudf._lib.column cimport Column, column, column_view -from cudf._lib.table cimport Table, table +from cudf._lib.table cimport table +from cudf._lib.utils cimport data_from_unique_ptr from cuspatial._lib.cpp.spatial_window cimport ( points_in_spatial_window as cpp_points_in_spatial_window, @@ -36,5 +37,4 @@ cpdef points_in_spatial_window( ) ) - table = Table.from_unique_ptr(move(c_result), column_names=["x", "y"]) - return table + return data_from_unique_ptr(move(c_result), column_names=["x", "y"]) diff --git a/python/cuspatial/cuspatial/_lib/trajectory.pyx b/python/cuspatial/cuspatial/_lib/trajectory.pyx index 88009d2a5..012439904 100644 --- a/python/cuspatial/cuspatial/_lib/trajectory.pyx +++ b/python/cuspatial/cuspatial/_lib/trajectory.pyx @@ -9,7 +9,7 @@ from cudf._lib.cpp.column.column cimport column from cudf._lib.cpp.column.column_view cimport column_view from cudf._lib.cpp.table.table cimport table from cudf._lib.cpp.types cimport size_type -from cudf._lib.table cimport Table +from cudf._lib.utils cimport data_from_unique_ptr from cuspatial._lib.cpp.trajectory cimport ( derive_trajectories as cpp_derive_trajectories, @@ -27,11 +27,10 @@ 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)) - table = Table.from_unique_ptr( + return data_from_unique_ptr( move(result.first), column_names=["object_id", "x", "y", "timestamp"] - ) - return table, Column.from_unique_ptr(move(result.second)) + ), Column.from_unique_ptr(move(result.second)) cpdef trajectory_bounding_boxes(size_type num_trajectories, @@ -44,7 +43,7 @@ cpdef trajectory_bounding_boxes(size_type num_trajectories, result = move(cpp_trajectory_bounding_boxes( num_trajectories, c_id, c_x, c_y )) - return Table.from_unique_ptr( + return data_from_unique_ptr( move(result), column_names=["x_min", "y_min", "x_max", "y_max"] ) @@ -62,7 +61,7 @@ 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 Table.from_unique_ptr( + return data_from_unique_ptr( move(result), column_names=["distance", "speed"] ) diff --git a/python/cuspatial/cuspatial/core/gis.py b/python/cuspatial/cuspatial/core/gis.py index 17fb369be..7ae5c0bd2 100644 --- a/python/cuspatial/cuspatial/core/gis.py +++ b/python/cuspatial/cuspatial/core/gis.py @@ -287,8 +287,8 @@ def polygon_bounding_boxes(poly_offsets, ring_offsets, xs, ys): poly_offsets = as_column(poly_offsets, dtype="int32") ring_offsets = as_column(ring_offsets, dtype="int32") xs, ys = normalize_point_columns(as_column(xs), as_column(ys)) - return DataFrame._from_table( - cpp_polygon_bounding_boxes(poly_offsets, ring_offsets, xs, ys) + return DataFrame._from_data( + *cpp_polygon_bounding_boxes(poly_offsets, ring_offsets, xs, ys) ) @@ -322,6 +322,6 @@ def polyline_bounding_boxes(poly_offsets, xs, ys, expansion_radius): """ poly_offsets = as_column(poly_offsets, dtype="int32") xs, ys = normalize_point_columns(as_column(xs), as_column(ys)) - return DataFrame._from_table( - cpp_polyline_bounding_boxes(poly_offsets, xs, ys, expansion_radius) + return DataFrame._from_data( + *cpp_polyline_bounding_boxes(poly_offsets, xs, ys, expansion_radius) ) diff --git a/python/cuspatial/cuspatial/core/indexing.py b/python/cuspatial/cuspatial/core/indexing.py index 57fc79d7d..23e8e48e4 100644 --- a/python/cuspatial/cuspatial/core/indexing.py +++ b/python/cuspatial/cuspatial/core/indexing.py @@ -173,4 +173,4 @@ def quadtree_on_points( max_depth, min_size, ) - return Series(key_to_point), DataFrame._from_table(quadtree) + return Series(key_to_point), DataFrame._from_data(*quadtree) diff --git a/python/cuspatial/cuspatial/core/interpolate.py b/python/cuspatial/cuspatial/core/interpolate.py index f8b311710..ef191e490 100644 --- a/python/cuspatial/cuspatial/core/interpolate.py +++ b/python/cuspatial/cuspatial/core/interpolate.py @@ -16,9 +16,9 @@ def _cubic_spline_coefficients(x, y, ids, prefix_sums): y_c = y._column ids_c = ids._column prefix_c = prefix_sums._column - result_table = cubicspline_coefficients(x_c, y_c, ids_c, prefix_c) - result = DataFrame._from_table(result_table) - return result + return DataFrame._from_data( + *cubicspline_coefficients(x_c, y_c, ids_c, prefix_c) + ) def _cubic_spline_fit(points, points_ids, prefixes, original_t, c): diff --git a/python/cuspatial/cuspatial/core/spatial_join.py b/python/cuspatial/cuspatial/core/spatial_join.py index 51dfdae07..004abd5bd 100644 --- a/python/cuspatial/cuspatial/core/spatial_join.py +++ b/python/cuspatial/cuspatial/core/spatial_join.py @@ -62,8 +62,8 @@ def join_quadtree_and_bounding_boxes( + "scale {}. Clamping to minimum scale".format(min_scale) ) - return DataFrame._from_table( - spatial_join.join_quadtree_and_bounding_boxes( + return DataFrame._from_data( + *spatial_join.join_quadtree_and_bounding_boxes( quadtree, poly_bounding_boxes, x_min, @@ -142,8 +142,8 @@ def quadtree_point_in_polygon( as_column(poly_points_x), as_column(poly_points_y), ) - return DataFrame._from_table( - spatial_join.quadtree_point_in_polygon( + return DataFrame._from_data( + *spatial_join.quadtree_point_in_polygon( poly_quad_pairs, quadtree, as_column(point_indices, dtype="uint32"), @@ -218,8 +218,8 @@ def quadtree_point_to_nearest_polyline( as_column(poly_points_x), as_column(poly_points_y), ) - return DataFrame._from_table( - spatial_join.quadtree_point_to_nearest_polyline( + return DataFrame._from_data( + *spatial_join.quadtree_point_to_nearest_polyline( poly_quad_pairs, quadtree, as_column(point_indices, dtype="uint32"), diff --git a/python/cuspatial/cuspatial/core/spatial_window.py b/python/cuspatial/cuspatial/core/spatial_window.py index d214219d5..3967adba5 100644 --- a/python/cuspatial/cuspatial/core/spatial_window.py +++ b/python/cuspatial/cuspatial/core/spatial_window.py @@ -43,7 +43,8 @@ def points_in_spatial_window(min_x, max_x, min_y, max_y, xs, ys): * Swaps ``min_y`` and ``max_y`` if ``min_y > max_y`` """ xs, ys = normalize_point_columns(as_column(xs), as_column(ys)) - result = spatial_window.points_in_spatial_window( - min_x, max_x, min_y, max_y, xs, ys + return DataFrame._from_data( + *spatial_window.points_in_spatial_window( + min_x, max_x, min_y, max_y, xs, ys + ) ) - return DataFrame._from_table(result) diff --git a/python/cuspatial/cuspatial/core/trajectory.py b/python/cuspatial/cuspatial/core/trajectory.py index 8df229e87..dba440578 100644 --- a/python/cuspatial/cuspatial/core/trajectory.py +++ b/python/cuspatial/cuspatial/core/trajectory.py @@ -68,7 +68,7 @@ def derive_trajectories(object_ids, xs, ys, timestamps): objects, traj_offsets = cpp_derive_trajectories( object_ids, xs, ys, timestamps ) - return DataFrame._from_table(objects), Series(data=traj_offsets) + return DataFrame._from_data(*objects), Series(data=traj_offsets) def trajectory_bounding_boxes(num_trajectories, object_ids, xs, ys): @@ -123,8 +123,8 @@ def trajectory_bounding_boxes(num_trajectories, object_ids, xs, ys): object_ids = as_column(object_ids, dtype=np.int32) xs, ys = normalize_point_columns(as_column(xs), as_column(ys)) - return DataFrame._from_table( - cpp_trajectory_bounding_boxes(num_trajectories, object_ids, xs, ys) + return DataFrame._from_data( + *cpp_trajectory_bounding_boxes(num_trajectories, object_ids, xs, ys) ) @@ -177,8 +177,8 @@ def trajectory_distances_and_speeds( object_ids = as_column(object_ids, dtype=np.int32) xs, ys = normalize_point_columns(as_column(xs), as_column(ys)) timestamps = normalize_timestamp_column(as_column(timestamps)) - df = DataFrame._from_table( - cpp_trajectory_distances_and_speeds( + df = DataFrame._from_data( + *cpp_trajectory_distances_and_speeds( num_trajectories, object_ids, xs, ys, timestamps ) ) diff --git a/python/cuspatial/cuspatial/geometry/geodataframe.py b/python/cuspatial/cuspatial/geometry/geodataframe.py index 4c3ab391d..a450f8946 100644 --- a/python/cuspatial/cuspatial/geometry/geodataframe.py +++ b/python/cuspatial/cuspatial/geometry/geodataframe.py @@ -122,9 +122,7 @@ def _copy_type_metadata(self, other, include_index: bool = True): ) and not isinstance( self._index, cudf.core.index.CategoricalIndex ): - self._index = cudf.core.index.Index._from_table( - self._index - ) + self._index = cudf.Index(self._index._column) return self