diff options
author | Yoshiki Vázquez Baeza <yoshiki.vazquezbaeza@colorado.edu> | 2014-03-25 22:19:03 -0600 |
---|---|---|
committer | Yoshiki Vázquez Baeza <yoshiki.vazquezbaeza@colorado.edu> | 2014-03-25 22:19:03 -0600 |
commit | 2e58804fe546bf6d476d09ba186c36a69bc577c4 (patch) | |
tree | 6e200bd3794cbabe31a2e80fe091c93b5f08cc9a /numpy/testing/utils.py | |
parent | 4112bf1a19f614fc426b82ff6b3ae86d8b25f92b (diff) | |
download | numpy-2e58804fe546bf6d476d09ba186c36a69bc577c4.tar.gz |
ENH: Add check for ndarray/scalar in build_err_msg
This check is needed now that build_err_msg takes a precision argument,
which is only relevant if the things being compared are ndarrays.
Diffstat (limited to 'numpy/testing/utils.py')
-rw-r--r-- | numpy/testing/utils.py | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py index b3bb17e61..930900bf2 100644 --- a/numpy/testing/utils.py +++ b/numpy/testing/utils.py @@ -9,8 +9,9 @@ import sys import re import operator import warnings +from functools import partial from .nosetester import import_nose -from numpy.core import float32, empty, arange, array_repr +from numpy.core import float32, empty, arange, array_repr, ndarray if sys.version_info[0] >= 3: from io import StringIO @@ -199,8 +200,15 @@ def build_err_msg(arrays, err_msg, header='Items are not equal:', msg.append(err_msg) if verbose: for i, a in enumerate(arrays): + + if isinstance(a, ndarray): + # precision argument is only needed if the objects are ndarrays + r_func = partial(array_repr, precision=precision) + else: + r_func = repr + try: - r = array_repr(a, precision=precision) + r = r_func(a) except: r = '[repr failed]' if r.count('\n') > 3: |