diff options
author | Jack J. Woehr <jwoehr@softwoehr.com> | 2019-10-18 15:25:03 -0600 |
---|---|---|
committer | Jack J. Woehr <jwoehr@softwoehr.com> | 2019-10-18 15:25:03 -0600 |
commit | cc3da40d52cb46a346bf429b8d76d7fd59e29887 (patch) | |
tree | 3a0cf76b27723817e5520d877df1685ce7f4223d /numpy/core/arrayprint.py | |
parent | 4d4cc4dcf4feaa6c3162b0d07b0f687e477724ad (diff) | |
parent | c1f56c455252e4c2dd2535f0ce140125aff8ece2 (diff) | |
download | numpy-cc3da40d52cb46a346bf429b8d76d7fd59e29887.tar.gz |
Merge branch 'master' of https://github.com/numpy/numpy into einsum_c_buglet
Diffstat (limited to 'numpy/core/arrayprint.py')
-rw-r--r-- | numpy/core/arrayprint.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 233d139fd..401018015 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -111,7 +111,7 @@ def set_printoptions(precision=None, threshold=None, edgeitems=None, ---------- precision : int or None, optional Number of digits of precision for floating point output (default 8). - May be `None` if `floatmode` is not `fixed`, to print as many digits as + May be None if `floatmode` is not `fixed`, to print as many digits as necessary to uniquely specify the value. threshold : int, optional Total number of array elements which trigger summarization @@ -1479,7 +1479,11 @@ def array_repr(arr, max_line_width=None, precision=None, suppress_small=None): arr, max_line_width, precision, suppress_small) -_guarded_str = _recursive_guard()(str) +@_recursive_guard() +def _guarded_repr_or_str(v): + if isinstance(v, bytes): + return repr(v) + return str(v) def _array_str_implementation( @@ -1497,7 +1501,7 @@ def _array_str_implementation( # obtain a scalar and call str on it, avoiding problems for subclasses # for which indexing with () returns a 0d instead of a scalar by using # ndarray's getindex. Also guard against recursive 0d object arrays. - return _guarded_str(np.ndarray.__getitem__(a, ())) + return _guarded_repr_or_str(np.ndarray.__getitem__(a, ())) return array2string(a, max_line_width, precision, suppress_small, ' ', "") |