Skip to content

Commit

Permalink
Merge branch 'branch-24.12' into ast-expr-enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
lamarrr authored Nov 4, 2024
2 parents 984e34f + 1d25d14 commit 6afd563
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 7 deletions.
28 changes: 21 additions & 7 deletions python/cudf/cudf/pandas/_wrappers/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,27 @@ def _pandas_util_dir():
# In pandas 2.0, pandas.util contains public APIs under
# __getattr__ but no __dir__ to find them
# https://github.com/pandas-dev/pandas/blob/2.2.x/pandas/util/__init__.py
return list(importlib.import_module("pandas.util").__dict__.keys()) + [
"hash_array",
"hash_pandas_object",
"Appender",
"Substitution",
"cache_readonly",
]
res = list(
set(
list(importlib.import_module("pandas.util").__dict__.keys())
+ [
"Appender",
"Substitution",
"_exceptions",
"_print_versions",
"cache_readonly",
"hash_array",
"hash_pandas_object",
"version",
"_tester",
"_validators",
"_decorators",
]
)
)
if cudf.core._compat.PANDAS_GE_220:
res.append("capitalize_first_letter")
return res


pd.util.__dir__ = _pandas_util_dir
Expand Down
18 changes: 18 additions & 0 deletions python/cudf/cudf_pandas_tests/test_cudf_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1759,3 +1759,21 @@ def test_fallback_raises_error(monkeypatch):
monkeycontext.setenv("CUDF_PANDAS_FAIL_ON_FALLBACK", "True")
with pytest.raises(ProxyFallbackError):
pd.Series(range(2)).astype(object)


@pytest.mark.parametrize(
"attrs",
[
"_exceptions",
"version",
"_print_versions",
"capitalize_first_letter",
"_validators",
"_decorators",
],
)
def test_cudf_pandas_util_version(attrs):
if not PANDAS_GE_220 and attrs == "capitalize_first_letter":
assert not hasattr(pd.util, attrs)
else:
assert hasattr(pd.util, attrs)

0 comments on commit 6afd563

Please sign in to comment.