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
ENH: adding casting option to numpy.stack. #21627
Changes from 15 commits
ea75651
5a252a9
2c921e0
c6ec33e
a05c709
48101bc
c0b3b2e
ec714a3
653aa1a
9b8d4cd
df2c73f
da11545
8296c43
7bf6781
ce0ae35
1e94f43
43eadef
94eb6c1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,16 @@ | ||||||
``casting`` and ``dtype`` keyword arguments for `numpy.stack` | ||||||
------------------------------------------------------------- | ||||||
The ``casting`` and ``dtype`` keyword arguments is now available for `numpy.stack`. | ||||||
To use it, write ``np.stack(..., dtype=None, casting='same_kind')``. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @melissawm, we already pushed the commits with those changes! |
||||||
|
||||||
|
||||||
``casting`` and ``dtype`` keyword arguments for `numpy.vstack` | ||||||
-------------------------------------------------------------- | ||||||
The ``casting`` and ``dtype`` keyword arguments is now available for `numpy.vstack`. | ||||||
To use it, write ``np.vstack(..., dtype=None, casting='same_kind')``. | ||||||
|
||||||
|
||||||
``casting`` and ``dtype`` keyword arguments for `numpy.hstack` | ||||||
-------------------------------------------------------------- | ||||||
The ``casting`` and ``dtype`` keyword arguments is now available for `numpy.hstack`. | ||||||
To use it, write ``np.hstack(..., dtype=None, casting='same_kind')``. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,8 +1,8 @@ | ||||||
from collections.abc import Sequence | ||||||
from typing import TypeVar, overload, Any, SupportsIndex | ||||||
|
||||||
from numpy import generic | ||||||
from numpy._typing import ArrayLike, NDArray, _ArrayLike | ||||||
from numpy import generic, _CastingKind | ||||||
from numpy._typing import ArrayLike, NDArray, _ArrayLike, DTypeLike | ||||||
|
||||||
_SCT = TypeVar("_SCT", bound=generic) | ||||||
_ArrayType = TypeVar("_ArrayType", bound=NDArray[Any]) | ||||||
|
@@ -31,32 +31,61 @@ def atleast_3d(arys: ArrayLike, /) -> NDArray[Any]: ... | |||||
def atleast_3d(*arys: ArrayLike) -> list[NDArray[Any]]: ... | ||||||
|
||||||
@overload | ||||||
def vstack(tup: Sequence[_ArrayLike[_SCT]]) -> NDArray[_SCT]: ... | ||||||
def vstack( | ||||||
tup: Sequence[_ArrayLike[_SCT]], | ||||||
*, | ||||||
dtype: DTypeLike = ..., | ||||||
casting: _CastingKind = ... | ||||||
) -> NDArray[_SCT]: ... | ||||||
@overload | ||||||
def vstack(tup: Sequence[ArrayLike]) -> NDArray[Any]: ... | ||||||
def vstack( | ||||||
tup: Sequence[ArrayLike], | ||||||
*, | ||||||
dtype: DTypeLike = ..., | ||||||
casting: _CastingKind = ... | ||||||
) -> NDArray[Any]: ... | ||||||
|
||||||
@overload | ||||||
def hstack(tup: Sequence[_ArrayLike[_SCT]]) -> NDArray[_SCT]: ... | ||||||
def hstack( | ||||||
tup: Sequence[_ArrayLike[_SCT]], | ||||||
*, | ||||||
dtype: DTypeLike = ..., | ||||||
casting: _CastingKind = ... | ||||||
) -> NDArray[_SCT]: ... | ||||||
@overload | ||||||
def hstack(tup: Sequence[ArrayLike]) -> NDArray[Any]: ... | ||||||
def hstack( | ||||||
tup: Sequence[ArrayLike], | ||||||
*, | ||||||
dtype: DTypeLike = ..., | ||||||
casting: _CastingKind = ... | ||||||
) -> NDArray[Any]: ... | ||||||
|
||||||
@overload | ||||||
def stack( | ||||||
arrays: Sequence[_ArrayLike[_SCT]], | ||||||
axis: SupportsIndex = ..., | ||||||
out: None = ..., | ||||||
out: None = ..., | ||||||
*, | ||||||
dtype: DTypeLike = ..., | ||||||
casting: _CastingKind = ... | ||||||
) -> NDArray[_SCT]: ... | ||||||
@overload | ||||||
def stack( | ||||||
arrays: Sequence[ArrayLike], | ||||||
axis: SupportsIndex = ..., | ||||||
out: None = ..., | ||||||
*, | ||||||
dtype: DTypeLike = ..., | ||||||
casting: _CastingKind = ... | ||||||
) -> NDArray[Any]: ... | ||||||
@overload | ||||||
def stack( | ||||||
arrays: Sequence[ArrayLike], | ||||||
axis: SupportsIndex = ..., | ||||||
out: _ArrayType = ..., | ||||||
out: None = ..., | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This specific There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Point of clarification: I'm referring to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @BvB93 sorry for that, we already pushed the changes for this error. Thanks for your patience. |
||||||
*, | ||||||
dtype: DTypeLike = ..., | ||||||
casting: _CastingKind = ... | ||||||
) -> _ArrayType: ... | ||||||
|
||||||
@overload | ||||||
|
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.
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 for all release notes below)