-
-
Notifications
You must be signed in to change notification settings - Fork 11.9k
ENH: Add dtype-support to 3 generic/ndarray methods
#19140
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
* `astype` * `getfield` * `view`
| @overload | ||
| def astype( | ||
| self, | ||
| dtype: _DTypeLike[_ScalarType], | ||
| order: _OrderKACF = ..., | ||
| casting: _Casting = ..., | ||
| subok: bool = ..., | ||
| copy: bool = ..., | ||
| ) -> NDArray[_ScalarType]: ... | ||
| @overload | ||
| def astype( | ||
| self, | ||
| dtype: DTypeLike, | ||
| order: _OrderKACF = ..., | ||
| casting: _Casting = ..., | ||
| subok: bool = ..., | ||
| copy: bool = ..., | ||
| ) -> NDArray[Any]: ... |
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.
dtype-support is, for now, limited to dtype-likes that can be parametrized w.r.t. np.generic.
For all others the dtype will be set to Any.
| @overload | ||
| def view( | ||
| self, | ||
| dtype: DTypeLike, | ||
| type: Type[_NdArraySubClass], | ||
| ) -> _NdArraySubClass: ... |
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.
Unfortunately we can't express the return of an ndarray-subclass with a specific dtype
(e.g. ndarray[float64] -> matrix[int64]). This would require higher-kinded TypeVars, which we don't have.
|
Thanks Bas. |
This PR adds dtype-support to the annotations of the following 3
generic/ndarraymethods:astypeviewgetfield