Skip to content

Commit

Permalink
Merge pull request #60 from rapidsai/wence/fix/index-again
Browse files Browse the repository at this point in the history
Fix index `__new__` again
  • Loading branch information
shwina committed Oct 10, 2023
2 parents 00c0f1c + 753c836 commit de49d59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
23 changes: 5 additions & 18 deletions python/cudf/cudf/pandas/_wrappers/pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
# its affiliates is strictly prohibited.

import sys
from typing import Iterator

import pandas as pd

Expand Down Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf/pandas/scripts/run-pandas-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit de49d59

Please sign in to comment.