From 2efc47c28bef46e66abd93133a4f90f186c920bc Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Tue, 10 Oct 2023 10:42:01 +0100 Subject: [PATCH 1/2] Simplify Index.__new__ constructor Don't need to separately call __init__ if we just call the fast/slow constructor. --- python/cudf/cudf/pandas/_wrappers/pandas.py | 23 +++++---------------- 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/python/cudf/cudf/pandas/_wrappers/pandas.py b/python/cudf/cudf/pandas/_wrappers/pandas.py index fcc54cc11f..ea9ebedb90 100644 --- a/python/cudf/cudf/pandas/_wrappers/pandas.py +++ b/python/cudf/cudf/pandas/_wrappers/pandas.py @@ -10,7 +10,6 @@ # its affiliates is strictly prohibited. import sys -from typing import Iterator import pandas as pd @@ -150,28 +149,16 @@ def _DataFrame__dir__(self): def Index__new__(cls, *args, **kwargs): - # Avoid consuming generators twice - # This is a "good enough" solution for this specific use case. - args = tuple( - list(arg) if isinstance(arg, Iterator) else arg for arg in args - ) - kwargs = { - k: list(v) if isinstance(v, Iterator) else v for k, v in kwargs.items() - } - # Make the object + # Call fast/slow constructor + # This takes care of running __init__ as well, but must be paired + # with a removal of the defaulted __init__ that + # make_final_proxy_type provides. self, _ = _fast_slow_function_call( - lambda cls, *args, **kwargs: cls.__new__(cls, *args, **kwargs), + lambda cls, *args, **kwargs: cls(*args, **kwargs), cls, *args, **kwargs, ) - # Call init - _fast_slow_function_call( - lambda self, *args, **kwargs: self.__init__(*args, **kwargs), - self, - *args, - **kwargs, - ) return self From 753c8362de03b7acee8e787650ff9057b3b2fba2 Mon Sep 17 00:00:00 2001 From: Lawrence Mitchell Date: Tue, 10 Oct 2023 10:43:02 +0100 Subject: [PATCH 2/2] Quote glob in find command so that the shell doesn't expand it --- python/cudf/cudf/pandas/scripts/run-pandas-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/cudf/cudf/pandas/scripts/run-pandas-tests.sh b/python/cudf/cudf/pandas/scripts/run-pandas-tests.sh index 886d822398..dd404708ca 100755 --- a/python/cudf/cudf/pandas/scripts/run-pandas-tests.sh +++ b/python/cudf/cudf/pandas/scripts/run-pandas-tests.sh @@ -92,7 +92,7 @@ EOF # Substitute `pandas.tests` with a relative import. # This will depend on the location of the test module relative to # the pandas-tests directory. - for hit in $(find . -iname *.py | xargs grep "pandas.tests" | cut -d ":" -f 1 | sort | uniq); do + for hit in $(find . -iname '*.py' | xargs grep "pandas.tests" | cut -d ":" -f 1 | sort | uniq); do # Get the relative path to the test module test_module=$(echo $hit | cut -d "/" -f 2-) # Get the number of directories to go up