diff --git a/python/cudf/cudf/_lib/cpp/types.pxd b/python/cudf/cudf/_lib/cpp/types.pxd index 14bf8a83de0..13aebdff726 100644 --- a/python/cudf/cudf/_lib/cpp/types.pxd +++ b/python/cudf/cudf/_lib/cpp/types.pxd @@ -1,58 +1,56 @@ -# Copyright (c) 2020-2023, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. from libc.stdint cimport int32_t, uint32_t +from libcpp cimport bool cdef extern from "cudf/types.hpp" namespace "cudf" nogil: - # The declaration below is to work around - # https://github.com/cython/cython/issues/5637 - """ - #define __PYX_ENUM_CLASS_DECL enum - """ ctypedef int32_t size_type ctypedef uint32_t bitmask_type ctypedef uint32_t char_utf8 - ctypedef enum mask_state: - UNALLOCATED "cudf::mask_state::UNALLOCATED" - UNINITIALIZED "cudf::mask_state::UNINITIALIZED" - ALL_VALID "cudf::mask_state::ALL_VALID" - ALL_NULL "cudf::mask_state::ALL_NULL" + # A Hack to let cython compile with __int128_t symbol + # https://stackoverflow.com/a/27609033 + ctypedef int int128 "__int128_t" - ctypedef enum order "cudf::order": - ASCENDING "cudf::order::ASCENDING" - DESCENDING "cudf::order::DESCENDING" + cpdef enum class mask_state(int32_t): + UNALLOCATED + UNINITIALIZED + ALL_VALID + ALL_NULL - ctypedef enum null_order "cudf::null_order": - AFTER "cudf::null_order::AFTER" - BEFORE "cudf::null_order::BEFORE" + cpdef enum class order(bool): + ASCENDING + DESCENDING - ctypedef enum sorted "cudf::sorted": - NO "cudf::sorted::NO" - YES "cudf::sorted::YES" + cpdef enum class null_order(bool): + AFTER + BEFORE + + cpdef enum class sorted(bool): + NO + YES cdef cppclass order_info: sorted is_sorted order ordering null_order null_ordering - ctypedef enum null_policy "cudf::null_policy": - EXCLUDE "cudf::null_policy::EXCLUDE" - INCLUDE "cudf::null_policy::INCLUDE" + cpdef enum class null_policy(bool): + EXCLUDE + INCLUDE - ctypedef enum nan_policy "cudf::nan_policy": - NAN_IS_NULL "cudf::nan_policy::NAN_IS_NULL" - NAN_IS_VALID "cudf::nan_policy::NAN_IS_VALID" + cpdef enum class nan_policy(bool): + NAN_IS_NULL + NAN_IS_VALID - ctypedef enum null_equality "cudf::null_equality": - EQUAL "cudf::null_equality::EQUAL" - UNEQUAL "cudf::null_equality::UNEQUAL" + cpdef enum class null_equality(bool): + EQUAL + UNEQUAL - ctypedef enum nan_equality "cudf::nan_equality": - # These names differ from the C++ names due to Cython warnings if - # "UNEQUAL" is declared by both null_equality and nan_equality. - ALL_EQUAL "cudf::nan_equality::ALL_EQUAL" - NANS_UNEQUAL "cudf::nan_equality::UNEQUAL" + cpdef enum class nan_equality(bool): + ALL_EQUAL + UNEQUAL cpdef enum class type_id(int32_t): EMPTY @@ -93,14 +91,9 @@ cdef extern from "cudf/types.hpp" namespace "cudf" nogil: type_id id() except + int32_t scale() except + -cdef extern from "cudf/types.hpp" namespace "cudf" nogil: - ctypedef enum interpolation: - LINEAR "cudf::interpolation::LINEAR" - LOWER "cudf::interpolation::LOWER" - HIGHER "cudf::interpolation::HIGHER" - MIDPOINT "cudf::interpolation::MIDPOINT" - NEAREST "cudf::interpolation::NEAREST" - - # A Hack to let cython compile with __int128_t symbol - # https://stackoverflow.com/a/27609033 - ctypedef int int128 "__int128_t" + cpdef enum class interpolation(int32_t): + LINEAR + LOWER + HIGHER + MIDPOINT + NEAREST diff --git a/python/cudf/cudf/_lib/lists.pyx b/python/cudf/cudf/_lib/lists.pyx index 199641fd2ce..f76d7a9a388 100644 --- a/python/cudf/cudf/_lib/lists.pyx +++ b/python/cudf/cudf/_lib/lists.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2021-2023, NVIDIA CORPORATION. +# Copyright (c) 2021-2024, NVIDIA CORPORATION. from cudf.core.buffer import acquire_spill_lock @@ -84,7 +84,7 @@ def distinct(Column col, bool nulls_equal, bool nans_all_equal): null_equality.EQUAL if nulls_equal else null_equality.UNEQUAL ) cdef nan_equality c_nans_equal = ( - nan_equality.ALL_EQUAL if nans_all_equal else nan_equality.NANS_UNEQUAL + nan_equality.ALL_EQUAL if nans_all_equal else nan_equality.UNEQUAL ) cdef unique_ptr[column] c_result diff --git a/python/cudf/cudf/_lib/stream_compaction.pyx b/python/cudf/cudf/_lib/stream_compaction.pyx index 9b22728d2f0..d7725e8df94 100644 --- a/python/cudf/cudf/_lib/stream_compaction.pyx +++ b/python/cudf/cudf/_lib/stream_compaction.pyx @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023, NVIDIA CORPORATION. +# Copyright (c) 2020-2024, NVIDIA CORPORATION. from cudf.core.buffer import acquire_spill_lock @@ -209,7 +209,7 @@ def distinct_indices( cdef nan_equality cpp_nans_equal = ( nan_equality.ALL_EQUAL if nans_equal - else nan_equality.NANS_UNEQUAL + else nan_equality.UNEQUAL ) cdef table_view source = table_view_from_columns(columns) cdef unique_ptr[column] c_result