-
Notifications
You must be signed in to change notification settings - Fork 912
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'branch-24.12' into misc/ci-cleanup
- Loading branch information
Showing
23 changed files
with
363 additions
and
80 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
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
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
6 changes: 6 additions & 0 deletions
6
docs/cudf/source/user_guide/api_docs/pylibcudf/strings/findall.rst
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 @@ | ||
==== | ||
find | ||
==== | ||
|
||
.. automodule:: pylibcudf.strings.findall | ||
: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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ strings | |
contains | ||
extract | ||
find | ||
findall | ||
regex_flags | ||
regex_program | ||
repeat | ||
|
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 |
---|---|---|
@@ -1,40 +1,25 @@ | ||
# Copyright (c) 2019-2024, NVIDIA CORPORATION. | ||
|
||
from cython.operator cimport dereference | ||
from libc.stdint cimport uint32_t | ||
from libcpp.memory cimport unique_ptr | ||
from libcpp.string cimport string | ||
from libcpp.utility cimport move | ||
|
||
from cudf.core.buffer import acquire_spill_lock | ||
|
||
from pylibcudf.libcudf.column.column cimport column | ||
from pylibcudf.libcudf.column.column_view cimport column_view | ||
from pylibcudf.libcudf.strings.findall cimport findall as cpp_findall | ||
from pylibcudf.libcudf.strings.regex_flags cimport regex_flags | ||
from pylibcudf.libcudf.strings.regex_program cimport regex_program | ||
|
||
from cudf._lib.column cimport Column | ||
|
||
import pylibcudf as plc | ||
|
||
|
||
@acquire_spill_lock() | ||
def findall(Column source_strings, object pattern, uint32_t flags): | ||
""" | ||
Returns data with all non-overlapping matches of `pattern` | ||
in each string of `source_strings` as a lists column. | ||
""" | ||
cdef unique_ptr[column] c_result | ||
cdef column_view source_view = source_strings.view() | ||
|
||
cdef string pattern_string = <string>str(pattern).encode() | ||
cdef regex_flags c_flags = <regex_flags>flags | ||
cdef unique_ptr[regex_program] c_prog | ||
|
||
with nogil: | ||
c_prog = move(regex_program.create(pattern_string, c_flags)) | ||
c_result = move(cpp_findall( | ||
source_view, | ||
dereference(c_prog) | ||
)) | ||
|
||
return Column.from_unique_ptr(move(c_result)) | ||
prog = plc.strings.regex_program.RegexProgram.create( | ||
str(pattern), flags | ||
) | ||
plc_result = plc.strings.findall.findall( | ||
source_strings.to_pylibcudf(mode="read"), | ||
prog, | ||
) | ||
return Column.from_pylibcudf(plc_result) |
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
100 changes: 100 additions & 0 deletions
100
python/cudf/cudf_pandas_tests/test_cudf_pandas_no_fallback.py
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,100 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2024, NVIDIA CORPORATION & AFFILIATES. | ||
# All rights reserved. | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
import pytest | ||
|
||
from cudf.pandas import LOADED | ||
|
||
if not LOADED: | ||
raise ImportError("These tests must be run with cudf.pandas loaded") | ||
|
||
import numpy as np | ||
import pandas as pd | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def fail_on_fallback(monkeypatch): | ||
monkeypatch.setenv("CUDF_PANDAS_FAIL_ON_FALLBACK", "True") | ||
|
||
|
||
@pytest.fixture | ||
def dataframe(): | ||
df = pd.DataFrame( | ||
{ | ||
"a": [1, 1, 1, 2, 3], | ||
"b": [1, 2, 3, 4, 5], | ||
"c": [1.2, 1.3, 1.5, 1.7, 1.11], | ||
} | ||
) | ||
return df | ||
|
||
|
||
@pytest.fixture | ||
def series(dataframe): | ||
return dataframe["a"] | ||
|
||
|
||
@pytest.fixture | ||
def array(series): | ||
return series.values | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"op", | ||
[ | ||
"sum", | ||
"min", | ||
"max", | ||
"mean", | ||
"std", | ||
"var", | ||
"prod", | ||
"median", | ||
], | ||
) | ||
def test_no_fallback_in_reduction_ops(series, op): | ||
s = series | ||
getattr(s, op)() | ||
|
||
|
||
def test_groupby(dataframe): | ||
df = dataframe | ||
df.groupby("a", sort=True).max() | ||
|
||
|
||
def test_no_fallback_in_binops(dataframe): | ||
df = dataframe | ||
df + df | ||
df - df | ||
df * df | ||
df**df | ||
df[["a", "b"]] & df[["a", "b"]] | ||
df <= df | ||
|
||
|
||
def test_no_fallback_in_groupby_rolling_sum(dataframe): | ||
df = dataframe | ||
df.groupby("a").rolling(2).sum() | ||
|
||
|
||
def test_no_fallback_in_concat(dataframe): | ||
df = dataframe | ||
pd.concat([df, df]) | ||
|
||
|
||
def test_no_fallback_in_get_shape(dataframe): | ||
df = dataframe | ||
df.shape | ||
|
||
|
||
def test_no_fallback_in_array_ufunc_op(array): | ||
np.add(array, array) | ||
|
||
|
||
def test_no_fallback_in_merge(dataframe): | ||
df = dataframe | ||
pd.merge(df * df, df + df, how="inner") | ||
pd.merge(df * df, df + df, how="outer") | ||
pd.merge(df * df, df + df, how="left") | ||
pd.merge(df * df, df + df, how="right") |
Oops, something went wrong.