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: Add the axis
and ndim
attributes to np.AxisError
#19459
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
73abbf0
ENH: Add the `axis` and `ndim` attributes to `np.AxisError`
BvB93 65dd177
MAINT: Let the new `AxisError` attributes survive pickling
BvB93 0d3962c
DOC: Update the `AxisError` documentation
BvB93 2ef77a3
TST: Update the `AxisError` tests
BvB93 6aa5881
DOC: Add a release note
BvB93 2e1d041
MAINT: Improve the description of `AxisError`s overloaded constructor
BvB93 3f2fe38
TST: Fix a few typing test failures
BvB93 38b0fc2
DOC: Clarify a fix a few parts of the `AxisError` docstrings
BvB93 cd7fcb3
DOC: Reguide fix
0270f4a
DOC: Replace `versionadded` with `versionchanged`
BvB93 16964ae
DOC: Mention that `AxisError` is a `ValueError` and `IndexError` subc…
BvB93 11f7edf
ENH: Delay assembling of the error message until `__str__` is called
BvB93 76968ef
DOC: Update the `AxisError` string representation in its docstring
7613ef4
DOC: Update `versionadded`-related information
1e27e0c
DOC: Fix sphinx warnings
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
The ``ndim`` and ``axis`` attributes have been added to `numpy.AxisError` | ||
------------------------------------------------------------------------- | ||
The ``ndim`` and ``axis`` parameters are now also stored as attributes | ||
within each `numpy.AxisError` instance. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
import numpy as np | ||
|
||
np.AxisError(1.0) # E: Argument 1 to "AxisError" has incompatible type | ||
np.AxisError(1, ndim=2.0) # E: Argument "ndim" to "AxisError" has incompatible type | ||
np.AxisError( | ||
2, msg_prefix=404 # E: Argument "msg_prefix" to "AxisError" has incompatible type | ||
) | ||
np.AxisError(1.0) # E: No overload variant | ||
np.AxisError(1, ndim=2.0) # E: No overload variant | ||
np.AxisError(2, msg_prefix=404) # E: No overload variant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
import numpy as np | ||
|
||
np.AxisError(1) | ||
np.AxisError("test") | ||
np.AxisError(1, ndim=2) | ||
np.AxisError(1, ndim=None) | ||
np.AxisError(1, ndim=2, msg_prefix="error") | ||
np.AxisError(1, ndim=2, msg_prefix=None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
A few other candidates the might be worthwhile to add here:
numpy/numpy/__init__.pyi
Lines 3646 to 3653 in 89babbd