Skip to content

Commit

Permalink
Address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt711 committed Jun 7, 2024
1 parent 276c095 commit 4a61868
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 12 deletions.
2 changes: 0 additions & 2 deletions python/cudf/cudf/pandas/_wrappers/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ def Timestamp_Timedelta__new__(cls, *args, **kwargs):
# hence this method is needed.
self, _ = _fast_slow_function_call(
lambda cls, args, kwargs: cls(*args, **kwargs),
cudf.options._env_get_bool("CUDF_PANDAS_DEBUGGING", False),
cls,
args,
kwargs,
Expand Down Expand Up @@ -254,7 +253,6 @@ def Index__new__(cls, *args, **kwargs):
# make_final_proxy_type provides.
self, _ = _fast_slow_function_call(
lambda cls, args, kwargs: cls(*args, **kwargs),
cudf.options._env_get_bool("CUDF_PANDAS_DEBUGGING", False),
cls,
args,
kwargs,
Expand Down
15 changes: 5 additions & 10 deletions python/cudf/cudf/pandas/fast_slow_proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,6 @@ def __init__(self, *args, **kwargs):
lambda cls, args, kwargs: setattr(
self, "_fsproxy_wrapped", cls(*args, **kwargs)
),
_env_get_bool("CUDF_PANDAS_DEBUGGING", False),
type(self),
args,
kwargs,
Expand Down Expand Up @@ -701,7 +700,6 @@ def __call__(self, *args, **kwargs) -> Any:
# TODO: When Python 3.11 is the minimum supported Python version
# this can use operator.call
call_operator,
_env_get_bool("CUDF_PANDAS_DEBUGGING", False),
self,
args,
kwargs,
Expand Down Expand Up @@ -816,7 +814,6 @@ def __get__(self, instance, owner) -> Any:
# for anything else, use a fast-slow attribute:
self._attr, _ = _fast_slow_function_call(
getattr,
_env_get_bool("CUDF_PANDAS_DEBUGGING", False),
owner,
self._name,
)
Expand All @@ -841,7 +838,6 @@ def __get__(self, instance, owner) -> Any:
)
return _fast_slow_function_call(
getattr,
_env_get_bool("CUDF_PANDAS_DEBUGGING", False),
instance,
self._name,
)[0]
Expand Down Expand Up @@ -879,15 +875,14 @@ def __name__(self, value):
setattr(self._fsproxy_slow, "__name__", value)


def _assert_fast_slow_eq(left, right, **kwargs):
assert_func = kwargs.get("assert_func", assert_eq)
def _assert_fast_slow_eq(left, right):
if _is_final_type(type(left)) or type(left) in NUMPY_TYPES:
assert_func(left, right)
assert_eq(left, right)


def _fast_slow_function_call(
func: Callable,
cudf_pandas_debugging: bool | None = None,
/,
*args,
**kwargs,
) -> Any:
Expand All @@ -914,7 +909,7 @@ def _fast_slow_function_call(
# try slow path
raise Exception()
fast = True
if cudf_pandas_debugging:
if _env_get_bool("CUDF_PANDAS_DEBUGGING", False):
try:
with nvtx.annotate(
"EXECUTE_SLOW_DEBUG",
Expand All @@ -934,7 +929,7 @@ def _fast_slow_function_call(
)
else:
try:
_assert_fast_slow_eq(result, slow_result, **kwargs)
_assert_fast_slow_eq(result, slow_result)
except AssertionError as e:
warnings.warn(
"The results from cudf and pandas were different. "
Expand Down

0 comments on commit 4a61868

Please sign in to comment.