Skip to content

Commit

Permalink
Add missing pylibcudf strings docs (#16471)
Browse files Browse the repository at this point in the history
Noticed a few missing pylibcudf string docs that were missed, added them here.

Authors:
  - https://github.com/brandon-b-miller
  - Thomas Li (https://github.com/lithomas1)

Approvers:
  - Thomas Li (https://github.com/lithomas1)

URL: #16471
  • Loading branch information
brandon-b-miller authored Aug 5, 2024
1 parent e0d1ac1 commit af57286
Show file tree
Hide file tree
Showing 8 changed files with 101 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
==========
capitalize
==========

.. automodule:: cudf._lib.pylibcudf.strings.capitalize
:members:
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
==========
char_types
==========

.. automodule:: cudf._lib.pylibcudf.strings.char_types
:members:
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
====
find
====

.. automodule:: cudf._lib.pylibcudf.strings.find
:members:
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ strings
.. toctree::
:maxdepth: 1

capitalize
char_types
contains
find
regex_flags
regex_program
replace
slice
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
===========
regex_flags
===========

.. automodule:: cudf._lib.pylibcudf.strings.regex_flags
:members:
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
=============
regex_program
=============

.. automodule:: cudf._lib.pylibcudf.strings.regex_program
:members:
48 changes: 47 additions & 1 deletion python/cudf/cudf/_lib/pylibcudf/strings/capitalize.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,22 @@ cpdef Column capitalize(
# TODO: default scalar values
# https://github.com/rapidsai/cudf/issues/15505
):

"""Returns a column of capitalized strings.
For details, see :cpp:func:`cudf::strings::capitalize`.
Parameters
----------
input : Column
String column
delimiters : Scalar, default None
Characters for identifying words to capitalize
Returns
-------
pylibcudf.Column
Column of strings capitalized from the input column
"""
cdef unique_ptr[column] c_result

if delimiters is None:
Expand All @@ -47,6 +62,23 @@ cpdef Column title(
Column input,
string_character_types sequence_type=string_character_types.ALPHA
):
"""Modifies first character of each word to upper-case and lower-cases
the rest.
For details, see :cpp:func:`cudf::strings::title`.
Parameters
----------
input : Column
String column
sequence_type : string_character_types, default string_character_types.ALPHA
The character type that is used when identifying words
Returns
-------
pylibcudf.Column
Column of titled strings
"""
cdef unique_ptr[column] c_result
with nogil:
c_result = cpp_capitalize.title(input.view(), sequence_type)
Expand All @@ -55,6 +87,20 @@ cpdef Column title(


cpdef Column is_title(Column input):
"""Checks if the strings in the input column are title formatted.
For details, see :cpp:func:`cudf::strings::is_title`.
Parameters
----------
input : Column
String column
Returns
-------
pylibcudf.Column
Column of type BOOL8
"""
cdef unique_ptr[column] c_result
with nogil:
c_result = cpp_capitalize.is_title(input.view())
Expand Down
19 changes: 19 additions & 0 deletions python/cudf/cudf/_lib/pylibcudf/strings/regex_program.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,31 @@ from cudf._lib.pylibcudf.strings.regex_flags cimport regex_flags


cdef class RegexProgram:
"""Regex program class.
This is the Cython representation of
:cpp:class:`cudf::strings::regex_program`.
Do not instantiate this class directly, use the `create` method.
"""
def __init__(self, *args, **kwargs):
raise ValueError("Do not instantiate RegexProgram directly, use create")

@staticmethod
def create(str pattern, int flags):
"""Create a program from a pattern.
For detils, see :cpp:func:`cudf::strings::regex_program::create`.
Parameters
----------
pattern : str
Regex pattern
flags : Uniont[int, RegexFlags]
Regex flags for interpreting special characters in the pattern
"""
cdef unique_ptr[regex_program] c_prog
cdef regex_flags c_flags
cdef string c_pattern = pattern.encode()
Expand Down

0 comments on commit af57286

Please sign in to comment.