Skip to content

TYP: to_numpy #41751

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

jbrockmendel
Copy link
Member

  • closes #xxxx
  • tests added / passed
  • Ensure all linting tests pass, see here for how to run them
  • whatsnew entry

Copy link
Member

@simonjayhawkins simonjayhawkins left a comment

Choose a reason for hiding this comment

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

Thanks @jbrockmendel Is this not covered by one of @Dr-Irv PRs?

@@ -191,7 +191,7 @@ def extract_bool_array(mask: ArrayLike) -> np.ndarray:
# We could have BooleanArray, Sparse[bool], ...
# Except for BooleanArray, this is equivalent to just
# np.asarray(mask, dtype=bool)
mask = mask.to_numpy(dtype=bool, na_value=False)
mask = mask.to_numpy(dtype=np.dtype("bool"), na_value=False)
Copy link
Member

Choose a reason for hiding this comment

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

this shouldn't need to be changed. Not sure without checking when the NpDtype alias was added, but pretty sure from memory that this is causing several issues (e.g. #41203 (review)) and needs to be fixed first. #41185

Copy link
Member Author

Choose a reason for hiding this comment

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

either way i guess. at some point it is going to be cast to a np.dtype object, so i see it as harmless

Copy link
Member

Choose a reason for hiding this comment

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

yes, but the change means that the to_numpy annotation is wrong and since it's public will give false positives to users.

@simonjayhawkins simonjayhawkins added ExtensionArray Extending pandas with custom dtypes or arrays. Typing type annotations, mypy/pyright type checking labels Jun 1, 2021
@Dr-Irv
Copy link
Contributor

Dr-Irv commented Jun 1, 2021

Thanks @jbrockmendel Is this not covered by one of @Dr-Irv PRs?

I haven't done to_numpy() yet, but in #41251 I changed the definition of NpDtype based on a suggestion by @simonjayhawkins so I would suggest getting that approved before approving this one.

@jbrockmendel
Copy link
Member Author

if this is handled elsewhere we can just close it

@jbrockmendel jbrockmendel deleted the typ-to_numpy branch June 9, 2021 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ExtensionArray Extending pandas with custom dtypes or arrays. Typing type annotations, mypy/pyright type checking
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants