-
-
Notifications
You must be signed in to change notification settings - Fork 19.4k
DEPR: Deprecate ravel #56053
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
DEPR: Deprecate ravel #56053
Changes from 1 commit
b2f2774
41f31aa
dd9cfe6
054ca87
5a15389
28fb76c
636e3c4
d48e5ca
146e1aa
5be6f6c
571bc1a
d54a80c
cf79da9
4afe81c
bd292ad
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -861,6 +861,11 @@ def ravel(self, order: str = "C") -> ArrayLike: | |||||
| >>> s.ravel() # doctest: +SKIP | ||||||
| array([1, 2, 3]) | ||||||
| """ | ||||||
| warnings.warn( | ||||||
| "Series.ravel is deprecated. Use numpy.ravel directly.", | ||||||
| FutureWarning, | ||||||
| stacklevel=find_stack_level(), | ||||||
|
||||||
| stacklevel=find_stack_level(), | |
| stacklevel=2, |
For a simple case like this where the warning is directly raised in the top-level method, I prefer setting it explicitly, which avoids potential hickups with the function (I think we had perf issues in certain cases, and this also avoids getting a wrong stacklevel in case we forget a use case of ravel in our own code base)
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.
sure
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.
Or maybe we should also point to
to_numpy()in case people use this to essentially get the numpy series (the "ravel" aspect never does something, since Series is already 1D)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.
or just "dont do it bc it isnt necessary"? (also should we deprecate Index.ravel?)
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.
Yes and yes
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.
That's not necessarily correct. If you rely on the current return value, i.e. if your code requires that the object is a 1D numpy array, and you currently use
ravelfor that, you do need to replace ravel with a conversion to numpy.(and that's actually how we were implicitly using it internally)