-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
BUG: ufunc on ragged object array emits a warning #15045
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
Comments
Also, there is a test that is creating a ragged array and emitting a warning, but the warning somehow slips under the radar of pytest, maybe because it is inside an |
The solution to the first problem is to pro-actively create the array with an >>> import numpy as np
>>> arr = np.array(["a", "b"], dtype=object)
>>> objs = np.array([arr, "foo", arr], dtype=object) # HERE
>>> np.sum(objs, axis=0) I am probably reacting to an overly-simplified example since this is a snippet from a more complex code base. |
@jbrockmendel is using |
@mattip @seberg thanks for the quick feedback. In the np.sum with strs case, the suggested workaround likely works. To get an idea for where else this comes up in the pandas codebase, see pandas-dev/pandas#30035 The change here https://github.com/pandas-dev/pandas/pull/30035/files?file-filters%5B%5D=.py#diff-d5ffc8f19bc8362967ce9ddd23026739R141 was needed to silence warnings caused by calling operator.mod (i dont remember what the inputs were off the top of my head) |
Closing the correct fix is to explicitly create the ndarray before calling a ufunc. |
After merging gh-14794 this emits a DeprecationWarning
xref gh-15041
The text was updated successfully, but these errors were encountered: