-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
ENH: Better error message for invalid axis #7916
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
xref GH7915 Currently, writing array.max(axis=[0, 1]) doesn't mention you can use a tuple for the axis argument -- it just says "an integer is required".
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,8 +7,8 @@ | |
from numpy.core.test_rational import rational, test_add, test_add_rationals | ||
from numpy.testing import ( | ||
TestCase, run_module_suite, assert_, assert_equal, assert_raises, | ||
assert_array_equal, assert_almost_equal, assert_array_almost_equal, | ||
assert_no_warnings | ||
assert_raises_regex, assert_array_equal, assert_almost_equal, | ||
assert_array_almost_equal, assert_no_warnings | ||
) | ||
|
||
|
||
|
@@ -1197,6 +1197,7 @@ def test_reduce_arguments(self): | |
assert_raises(TypeError, f, d, axis="invalid") | ||
assert_raises(TypeError, f, d, axis="invalid", dtype=None, | ||
keepdims=True) | ||
assert_raises_regex(TypeError, "integer or tuple", f, d, axis=[0]) | ||
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. Apparently a list raises a different error. 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. Seems to come from python rather than numpy. 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. it comes from the PyNumber_Index here https://github.com/numpy/numpy/blob/master/numpy/core/src/multiarray/conversion_utils.c#L848 |
||
# invalid dtype | ||
assert_raises(TypeError, f, d, 0, "invalid") | ||
assert_raises(TypeError, f, d, dtype="invalid") | ||
|
@@ -1212,7 +1213,7 @@ def test_reduce_arguments(self): | |
assert_raises(TypeError, f, d, 0, keepdims="invalid", dtype="invalid", | ||
out=None) | ||
|
||
# invalid keyord | ||
# invalid keyword | ||
assert_raises(TypeError, f, d, axis=0, dtype=None, invalid=0) | ||
assert_raises(TypeError, f, d, invalid=0) | ||
assert_raises(TypeError, f, d, 0, keepdims=True, invalid="invalid", | ||
|
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.
Maybe
tuple of integers
?