summaryrefslogtreecommitdiff
path: root/numpy/core/_internal.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/core/_internal.py')
-rw-r--r--numpy/core/_internal.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/numpy/core/_internal.py b/numpy/core/_internal.py
index f25159d8e..01741cd1a 100644
--- a/numpy/core/_internal.py
+++ b/numpy/core/_internal.py
@@ -645,3 +645,15 @@ class AxisError(ValueError, IndexError):
msg = "{}: {}".format(msg_prefix, msg)
super(AxisError, self).__init__(msg)
+
+
+def array_ufunc_errmsg_formatter(ufunc, method, *inputs, **kwargs):
+ """ Format the error message for when __array_ufunc__ gives up. """
+ args_string = ', '.join(['{!r}'.format(arg) for arg in inputs] +
+ ['{}={!r}'.format(k, v)
+ 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}, {}): {}'
+ .format(ufunc, method, args_string, types_string))