-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
changed shape argument for ndarray from int to tuple in ./core/strings/object_array.py #44352
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
Conversation
pandas/core/strings/object_array.py:65: error: Argument "dtype" to "ndarray" has incompatible type "Union[ExtensionDtype, str, dtype[object_], dtype[Any], Type[object]]"; expected "Union[dtype[Any], None, type, _SupportsDType[dtype[Any]], str, Union[Tuple[Any, int], Tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any], _DTypeDict, Tuple[Any, Any]]]" [arg-type] |
pandas/core/strings/object_array.py
Outdated
# error: Argument 1 to "ndarray" has incompatible type "int"; | ||
# expected "Sequence[int]" | ||
return np.ndarray(0, dtype=dtype) # type: ignore[arg-type] | ||
return np.ndarray((0,), dtype=dtype) |
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.
best guess is this is intended to use np.array, not np.ndarray
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.
@jbrockmendel Thank you! I am new to this and appreciate the help. So you think calling np.array with similar arguments is needed instead of np.ndarray?
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.
@jbrockmendel also, I tried using pd.test() on my local machine and I didn't get this error message. Any advice on how to test before i push again?
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.
it should probably be np.array([], dtype=dtype)
.
I tried using pd.test() on my local machine and I didn't get this error message. Any advice on how to test before i push again?
Are you referring to the 'Argument 1 to "ndarray" ...'? That would show up if you a) removed the "type: ignore[arg-type]" and then ran 'mypy pandas'
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.
@jbrockmendel awesome, thank you! I will try this out.
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.
@jbrockmendel I am having trouble figuring out how to address the type errors for argument dtype. The suggestion you made about np.array instead of np.ndarray didn't solve the problem. Should I close this pr if I cannot figure it out?
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.
I am going to close this pull request for now. I am going to research the problem further, and come back to this once I have a good working solution. Thank you for helping me get started.
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.
what went wrong with np.array([], dtype=dtype)
?
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.
same type error as with the np.ndarray
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.
looks like it is a similar error but now complaining about the dtype rather than the first arg
error: Argument "dtype" to "array" has incompatible type "Union[ExtensionDtype, str, dtype[object_], dtype[Any], Type[object]]"; expected "Union[dtype[Any], None, type, _SupportsDType[dtype[Any]], str, Union[Tuple[Any, int], Tuple[Any, Union[SupportsIndex, Sequence[SupportsIndex]]], List[Any], _DTypeDict, Tuple[Any, Any]]]" [arg-type]
this might be fixed by changing the annotaiton for 'dtype' from Dtype | None
to NpDtype | None
; @simonjayhawkins may know more than me about the intention here.
@jbrockmendel How are you today? Do you think these changes could work? |
lgtm cc @simonjayhawkins |
thanks @nickleus27 |
xref #37715