Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BaseOffset as a final proxy type to pass instancechecks for offsets against BaseOffset #14678

Merged
merged 8 commits into from
Jan 19, 2024
11 changes: 10 additions & 1 deletion python/cudf/cudf/pandas/_wrappers/pandas.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.
# SPDX-FileCopyrightText: Copyright (c) 2023-2024 NVIDIA CORPORATION & AFFILIATES.
# All rights reserved.
# SPDX-License-Identifier: Apache-2.0
import copyreg
Expand Down Expand Up @@ -1036,6 +1036,15 @@ def _df_query_method(self, *args, local_dict=None, global_dict=None, **kwargs):
additional_attributes={"__hash__": _FastSlowAttribute("__hash__")},
)

BaseOffset = make_final_proxy_type(
"BaseOffset",
_Unusable,
pd.offsets.BaseOffset,
fast_to_slow=_Unusable(),
slow_to_fast=_Unusable(),
additional_attributes={"__hash__": _FastSlowAttribute("__hash__")},
)

Day = make_final_proxy_type(
"Day",
_Unusable,
Expand Down
5 changes: 5 additions & 0 deletions python/cudf/cudf_pandas_tests/test_cudf_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1233,3 +1233,8 @@ def test_concat_fast():
def test_func_namespace():
# note: this test is sensitive to Pandas' internal module layout
assert xpd.concat is xpd.core.reshape.concat.concat


def test_isinstance_base_offset():
offset = xpd.tseries.frequencies.to_offset("1s")
assert isinstance(offset, xpd.tseries.offsets.BaseOffset)