diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2017-05-10 12:31:24 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-10 12:31:24 -0600 |
commit | 0fefb94edf3d30e4336a43df4f36bbf46a018da9 (patch) | |
tree | 79da034d7679c5a78fe560100af0c2772fb35a6b /numpy | |
parent | a65fa8dd7bb6ba5cdefe8572b9074f849d1ceb29 (diff) | |
parent | e571559ded7f041acdb5130f5f8722fea44ff4ad (diff) | |
download | numpy-0fefb94edf3d30e4336a43df4f36bbf46a018da9.tar.gz |
Merge pull request #9089 from shoyer/array-ufunc-error-message
MAINT: refine error message for __array_ufunc__ not implemented
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/core/_internal.py | 5 | ||||
-rw-r--r-- | numpy/core/tests/test_umath.py | 10 |
2 files changed, 8 insertions, 7 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py index 10fcbfdfe..9c46b3297 100644 --- a/numpy/core/_internal.py +++ b/numpy/core/_internal.py @@ -695,10 +695,11 @@ def array_ufunc_errmsg_formatter(dummy, ufunc, method, *inputs, **kwargs): for k, v in kwargs.items()]) args = inputs + kwargs.get('out', ()) types_string = ', '.join(repr(type(arg).__name__) for arg in args) - return ('operand type(s) do not implement __array_ufunc__' - '({!r}, {!r}, {}): {}' + return ('operand type(s) all returned NotImplemented from ' + '__array_ufunc__({!r}, {!r}, {}): {}' .format(ufunc, method, args_string, types_string)) + def _ufunc_doc_signature_formatter(ufunc): """ Builds a signature string which resembles PEP 457 diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py index 13f29504a..9e849df92 100644 --- a/numpy/core/tests/test_umath.py +++ b/numpy/core/tests/test_umath.py @@ -1931,14 +1931,14 @@ class TestSpecialMethods(TestCase): def __array_ufunc__(self, *args, **kwargs): return NotImplemented - msg = ("operand type(s) do not implement __array_ufunc__(" - "<ufunc 'negative'>, '__call__', <*>): 'A'") + msg = ("operand type(s) all returned NotImplemented from " + "__array_ufunc__(<ufunc 'negative'>, '__call__', <*>): 'A'") with assert_raises_regex(TypeError, fnmatch.translate(msg)): np.negative(A()) - msg = ("operand type(s) do not implement __array_ufunc__(" - "<ufunc 'add'>, '__call__', <*>, <object *>, out=(1,)): " - "'A', 'object', 'int'") + msg = ("operand type(s) all returned NotImplemented from " + "__array_ufunc__(<ufunc 'add'>, '__call__', <*>, <object *>, " + "out=(1,)): 'A', 'object', 'int'") with assert_raises_regex(TypeError, fnmatch.translate(msg)): np.add(A(), object(), out=1) |