-
Notifications
You must be signed in to change notification settings - Fork 920
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose type traits to pylibcudf (#16197)
Rather than recreating the classification, OAOO by using the libcudf definitions. Authors: - Lawrence Mitchell (https://github.com/wence-) Approvers: - Bradley Dice (https://github.com/bdice) URL: #16197
- Loading branch information
Showing
13 changed files
with
361 additions
and
75 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
====== | ||
traits | ||
====== | ||
|
||
.. automodule:: cudf._lib.pylibcudf.traits | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
python/cudf/cudf/_lib/pylibcudf/libcudf/utilities/traits.pxd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. | ||
|
||
from libcpp cimport bool | ||
from libcpp.vector cimport vector | ||
|
||
from cudf._lib.pylibcudf.libcudf.types cimport data_type | ||
|
||
|
||
cdef extern from "cudf/utilities/traits.hpp" namespace "cudf" nogil: | ||
cdef bool is_relationally_comparable(data_type) | ||
cdef bool is_equality_comparable(data_type) | ||
cdef bool is_numeric(data_type) | ||
cdef bool is_index_type(data_type) | ||
cdef bool is_unsigned(data_type) | ||
cdef bool is_integral(data_type) | ||
cdef bool is_integral_not_bool(data_type) | ||
cdef bool is_floating_point(data_type) | ||
cdef bool is_boolean(data_type) | ||
cdef bool is_timestamp(data_type) | ||
cdef bool is_fixed_point(data_type) | ||
cdef bool is_duration(data_type) | ||
cdef bool is_chrono(data_type) | ||
cdef bool is_dictionary(data_type) | ||
cdef bool is_fixed_width(data_type) | ||
cdef bool is_compound(data_type) | ||
cdef bool is_nested(data_type) | ||
cdef bool is_bit_castable(data_type, data_type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. | ||
|
||
from libcpp cimport bool | ||
|
||
from .types cimport DataType | ||
|
||
|
||
cpdef bool is_relationally_comparable(DataType typ) | ||
cpdef bool is_equality_comparable(DataType typ) | ||
cpdef bool is_numeric(DataType typ) | ||
cpdef bool is_index_type(DataType typ) | ||
cpdef bool is_unsigned(DataType typ) | ||
cpdef bool is_integral(DataType typ) | ||
cpdef bool is_integral_not_bool(DataType typ) | ||
cpdef bool is_floating_point(DataType typ) | ||
cpdef bool is_boolean(DataType typ) | ||
cpdef bool is_timestamp(DataType typ) | ||
cpdef bool is_fixed_point(DataType typ) | ||
cpdef bool is_duration(DataType typ) | ||
cpdef bool is_chrono(DataType typ) | ||
cpdef bool is_dictionary(DataType typ) | ||
cpdef bool is_fixed_width(DataType typ) | ||
cpdef bool is_compound(DataType typ) | ||
cpdef bool is_nested(DataType typ) | ||
cpdef bool is_bit_castable(DataType source, DataType target) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
# Copyright (c) 2024, NVIDIA CORPORATION. | ||
|
||
from libcpp cimport bool | ||
|
||
from cudf._lib.pylibcudf.libcudf.utilities cimport traits | ||
|
||
from .types cimport DataType | ||
|
||
|
||
cpdef bool is_relationally_comparable(DataType typ): | ||
"""Checks if the given data type supports relational comparisons. | ||
For details, see :cpp:func:`is_relationally_comparable`. | ||
""" | ||
return traits.is_relationally_comparable(typ.c_obj) | ||
|
||
|
||
cpdef bool is_equality_comparable(DataType typ): | ||
"""Checks if the given data type supports equality comparisons. | ||
For details, see :cpp:func:`is_equality_comparable`. | ||
""" | ||
return traits.is_equality_comparable(typ.c_obj) | ||
|
||
|
||
cpdef bool is_numeric(DataType typ): | ||
"""Checks if the given data type is numeric. | ||
For details, see :cpp:func:`is_numeric`. | ||
""" | ||
return traits.is_numeric(typ.c_obj) | ||
|
||
|
||
cpdef bool is_index_type(DataType typ): | ||
"""Checks if the given data type is an index type. | ||
For details, see :cpp:func:`is_index_type`. | ||
""" | ||
return traits.is_index_type(typ.c_obj) | ||
|
||
|
||
cpdef bool is_unsigned(DataType typ): | ||
"""Checks if the given data type is an unsigned type. | ||
For details, see :cpp:func:`is_unsigned`. | ||
""" | ||
return traits.is_unsigned(typ.c_obj) | ||
|
||
|
||
cpdef bool is_integral(DataType typ): | ||
"""Checks if the given data type is an integral type. | ||
For details, see :cpp:func:`is_integral`. | ||
""" | ||
return traits.is_integral(typ.c_obj) | ||
|
||
|
||
cpdef bool is_integral_not_bool(DataType typ): | ||
"""Checks if the given data type is an integral type excluding booleans. | ||
For details, see :cpp:func:`is_integral_not_bool`. | ||
""" | ||
return traits.is_integral_not_bool(typ.c_obj) | ||
|
||
|
||
cpdef bool is_floating_point(DataType typ): | ||
"""Checks if the given data type is a floating point type. | ||
For details, see :cpp:func:`is_floating_point`. | ||
""" | ||
return traits.is_floating_point(typ.c_obj) | ||
|
||
|
||
cpdef bool is_boolean(DataType typ): | ||
"""Checks if the given data type is a boolean type. | ||
For details, see :cpp:func:`is_boolean`. | ||
""" | ||
return traits.is_boolean(typ.c_obj) | ||
|
||
|
||
cpdef bool is_timestamp(DataType typ): | ||
"""Checks if the given data type is a timestamp type. | ||
For details, see :cpp:func:`is_timestamp`. | ||
""" | ||
return traits.is_timestamp(typ.c_obj) | ||
|
||
|
||
cpdef bool is_fixed_point(DataType typ): | ||
"""Checks if the given data type is a fixed point type. | ||
For details, see :cpp:func:`is_fixed_point`. | ||
""" | ||
return traits.is_fixed_point(typ.c_obj) | ||
|
||
|
||
cpdef bool is_duration(DataType typ): | ||
"""Checks if the given data type is a duration type. | ||
For details, see :cpp:func:`is_duration`. | ||
""" | ||
return traits.is_duration(typ.c_obj) | ||
|
||
|
||
cpdef bool is_chrono(DataType typ): | ||
"""Checks if the given data type is a chrono type. | ||
For details, see :cpp:func:`is_chrono`. | ||
""" | ||
return traits.is_chrono(typ.c_obj) | ||
|
||
|
||
cpdef bool is_dictionary(DataType typ): | ||
"""Checks if the given data type is a dictionary type. | ||
For details, see :cpp:func:`is_dictionary`. | ||
""" | ||
return traits.is_dictionary(typ.c_obj) | ||
|
||
|
||
cpdef bool is_fixed_width(DataType typ): | ||
"""Checks if the given data type is a fixed width type. | ||
For details, see :cpp:func:`is_fixed_width`. | ||
""" | ||
return traits.is_fixed_width(typ.c_obj) | ||
|
||
|
||
cpdef bool is_compound(DataType typ): | ||
"""Checks if the given data type is a compound type. | ||
For details, see :cpp:func:`is_compound`. | ||
""" | ||
return traits.is_compound(typ.c_obj) | ||
|
||
|
||
cpdef bool is_nested(DataType typ): | ||
"""Checks if the given data type is a nested type. | ||
For details, see :cpp:func:`is_nested`. | ||
""" | ||
return traits.is_nested(typ.c_obj) | ||
|
||
|
||
cpdef bool is_bit_castable(DataType source, DataType target): | ||
"""Checks if the source type is bit-castable to the target type. | ||
For details, see :cpp:func:`is_bit_castable`. | ||
""" | ||
return traits.is_bit_castable(source.c_obj, target.c_obj) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.