Skip to content

DEPR: Series.ravel #52722

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
wants to merge 1 commit into from
Closed

Conversation

marechaux
Copy link

@phofl
Copy link
Member

phofl commented Apr 19, 2023

I'll have to take a closer look here, looks like we are using this internally. Will get to this over the weekend. pr itself is good!

@marechaux
Copy link
Author

marechaux commented Apr 20, 2023

Thanks for your answer, Should I replace the internal usage of this function ?

@phofl
Copy link
Member

phofl commented Apr 20, 2023

I'll have to check what we are doing before I can give you a definitiv answer here

@jorisvandenbossche
Copy link
Member

One place where we use ravel() internally that seems to cause many of the failures is in maybe_downcast_numeric:

if dtype.kind in "biu":
if not result.size:
# if we don't have any elements, just astype it
return trans(result).astype(dtype)
# do a test on the first element, if it fails then we are done
r = result.ravel()
arr = np.array([r[0]])

Changing r = result.ravel() to r = np.ravel(result) might be sufficient (assuming this won't dispatch to the method), or otherwise r = np.asarray(result).ravel() (we know at this point we have a numpy dtyped Series, so np.asarray(..) is cheap)

In theory we should not call this method with a Series though, but with an array (or, the type annotation is wrong)

@jbrockmendel
Copy link
Member

Thanks for your answer, Should I replace the internal usage of this function ?

Yes.

In theory we should not call this method with a Series though, but with an array (or, the type annotation is wrong)

Agreed.

@marechaux marechaux force-pushed the deprecate-series-ravel branch from 45fb051 to d8079e4 Compare April 21, 2023 15:31
Copy link
Member

@phofl phofl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two quick changes to get ci green (hopefully):

  • in assert_is_valid_plot_return_object there is still a ravel on a Series object. I'd recommend calling np.asarray(obj) and call ravel on the array
  • FAILED pandas/tests/copy_view/test_array.py::test_ravel_read_only[F] You have to use tm.assert_produces_warning here

@github-actions
Copy link
Contributor

This pull request is stale because it has been open for thirty days with no activity. Please update and respond to this comment if you're still interested in working on this.

@github-actions github-actions bot added the Stale label May 23, 2023
@mroeschke
Copy link
Member

Thanks for the pull request, but it appears to have gone stale. If interested in continuing, please merge in the main branch, address any review comments and/or failing tests, and we can reopen.

@mroeschke mroeschke closed this May 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Sprints Sprint Pull Requests Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DEPR: Deprecate Series.ravel
5 participants