-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
COMPAT: np 1.18 wants explicit dtype=object) #30035
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
bd1b261
COMPAT: np 1.18 wants explicit dtype=object)
jbrockmendel af573eb
suppress more
jbrockmendel fa5df88
Merge branch 'master' of https://github.com/pandas-dev/pandas into ci…
jbrockmendel 1c6c7ff
reenable npdev build
jbrockmendel 8f10b6a
Merge branch 'master' of https://github.com/pandas-dev/pandas into ci…
jbrockmendel 4be57a6
Merge branch 'master' of https://github.com/pandas-dev/pandas into ci…
jbrockmendel 77c592f
Merge branch 'master' of https://github.com/pandas-dev/pandas into ci…
jbrockmendel 1ba69b1
fix merge mixup
jbrockmendel 5ebff2e
post-merge fixups
jbrockmendel 52ae9df
Merge branch 'master' of https://github.com/pandas-dev/pandas into ci…
jbrockmendel 3584dab
revert kludges
jbrockmendel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
suppress more
- Loading branch information
commit af573eb44fde1b682d49a9da51a5592652c16f9c
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
""" | ||
Utility functions related to concat | ||
""" | ||
import warnings | ||
|
||
import numpy as np | ||
|
||
|
@@ -134,6 +135,7 @@ def is_nonempty(x) -> bool: | |
# coerce to object | ||
to_concat = [x.astype("object") for x in to_concat] | ||
|
||
to_concat = [_safe_array(x) for x in to_concat] | ||
return np.concatenate(to_concat, axis=axis) | ||
|
||
|
||
|
@@ -172,7 +174,7 @@ def concat_categorical(to_concat, axis: int = 0): | |
to_concat = [ | ||
x._internal_get_values() | ||
if is_categorical_dtype(x.dtype) | ||
else np.asarray(x).ravel() | ||
else _safe_array(x).ravel() | ||
if not is_datetime64tz_dtype(x) | ||
else np.asarray(x.astype(object)) | ||
for x in to_concat | ||
|
@@ -183,6 +185,15 @@ def concat_categorical(to_concat, axis: int 6D40 = 0): | |
return result | ||
|
||
|
||
def _safe_array(x): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so i actually like this as a real function; can you move to pandas.compat.numpy and use everywhere? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you do this one |
||
# FIXME: kludge | ||
with warnings.catch_warnings(): | ||
# See https://github.com/numpy/numpy/issues/15041 | ||
warnings.filterwarnings("ignore", ".*with automatic object dtype.*") | ||
arr = np.asarray(x) | ||
return arr | ||
|
||
|
||
def union_categoricals( | ||
to_union, sort_categories: bool = False, ignore_order: bool = False | ||
): | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be fixed at the caller, not here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yah, pretty much every usage where we're just suppressing the warnings was a kludge
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My thought for a way forward with the new sentinel in numpy/numpy#15119 is that you would leave this unchanged. When needed you would add the sentinel as the dtype in the call to
_from_sequence
(or even to whoever is calling_from_sequence
. During the deprecation period, try to rework the use case that justifies the inefficient ragged array, and get back to NumPy with the use case for such a construct so we can stop or rethink the deprecation.