-
Notifications
You must be signed in to change notification settings - Fork 914
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
[FEA] Proxy ndarrays don't pass an instancecheck()
for np.ndarray
#14537
Comments
As far as I can see there isn't a fix for this because we cannot modify import cudf.pandas
cudf.pandas.install()
import pandas as pd
import numpy as np
x = pd.Series([1,2]).to_numpy() # proxy for numpy.ndarray
isinstance(x, np.ndarray) # calls np.ndarray.__instancecheck__(x) which returns false I thought you might be able to modify TypeError: cannot set '__instancecheck__' attribute of immutable type 'numpy.ndarray' |
That's correct. I don't think there's a very good solution here, short of proxying |
Closes rapidsai#14537. Authors: - Matthew Murray (https://github.com/Matt711) - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - Matthew Roeschke (https://github.com/mroeschke) - Vyas Ramasubramani (https://github.com/vyasr) URL: rapidsai#16601
Closes rapidsai#14537. Authors: - Matthew Murray (https://github.com/Matt711) - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - GALI PREM SAGAR (https://github.com/galipremsagar) - Matthew Roeschke (https://github.com/mroeschke) - Vyas Ramasubramani (https://github.com/vyasr) URL: rapidsai#16601
There's a lot of code out there that does something like:
This is a problem for
cudf.pandas
, because proxy ndarray types, such as those returned bypd.Series.values
do not pass theisinstance()
check.Ideally, more projects would avoid doing a hard
isinstance()
check and instead use something like EAFP:..but that is not the world we live in today. Too many third-party libraries that people want to use with
cudf.pandas
use the pattern above, so it's on us to solve the problem right now.The text was updated successfully, but these errors were encountered: