Skip to content

Commit

Permalink
Merge branch 'branch-24.04' into bug-memcheck-test
Browse files Browse the repository at this point in the history
  • Loading branch information
jakirkham authored Feb 29, 2024
2 parents 1a8303a + f7e4860 commit 653a91e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
26 changes: 26 additions & 0 deletions python/cudf/cudf/_lib/pylibcudf/column.pyx
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
# Copyright (c) 2023-2024, NVIDIA CORPORATION.

from cython.operator cimport dereference
from libcpp.memory cimport unique_ptr
from libcpp.utility cimport move

from rmm._lib.device_buffer cimport DeviceBuffer

from cudf._lib.cpp.column.column cimport column, column_contents
from cudf._lib.cpp.column.column_factories cimport make_column_from_scalar
from cudf._lib.cpp.scalar.scalar cimport scalar
from cudf._lib.cpp.types cimport size_type

from .gpumemoryview cimport gpumemoryview
from .scalar cimport Scalar
from .types cimport DataType, type_id
from .utils cimport int_to_bitmask_ptr, int_to_void_ptr

Expand Down Expand Up @@ -196,6 +200,28 @@ cdef class Column:
children,
)

@staticmethod
def from_scalar(Scalar slr, size_type size):
"""Create a Column from a Scalar.
Parameters
----------
slr : Scalar
The scalar to create a column from.
size : size_type
The number of elements in the column.
Returns
-------
Column
A Column containing the scalar repeated `size` times.
"""
cdef const scalar* c_scalar = slr.get()
cdef unique_ptr[column] c_result
with nogil:
c_result = move(make_column_from_scalar(dereference(c_scalar), size))
return Column.from_libcudf(move(c_result))

cpdef DataType type(self):
"""The type of data in the column."""
return self._data_type
Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -1958,7 +1958,7 @@ def __dask_tokenize__(self):

return [
type(self),
normalize_token(self._dtypes),
str(self._dtypes),
normalize_token(self.to_pandas()),
]

Expand Down

0 comments on commit 653a91e

Please sign in to comment.