From db487c204c9df0472642d14d80632382463ecbcc Mon Sep 17 00:00:00 2001 From: Travis Oliphant Date: Fri, 8 Dec 2006 03:23:10 +0000 Subject: Add feature so that user-defined types can be recognized when instances of scalars of those types are present in the nested sequence. --- numpy/core/arrayprint.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'numpy/core/arrayprint.py') diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 42ec4cadb..f82f5ee21 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -144,23 +144,23 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ', try: format_function = a._format except AttributeError: - dtype = a.dtype.type - if issubclass(dtype, _nt.bool): + dtypeobj = a.dtype.type + if issubclass(dtypeobj, _nt.bool): format = "%s" format_function = lambda x: format % x - if issubclass(dtype, _nt.integer): + if issubclass(dtypeobj, _nt.integer): max_str_len = max(len(str(max_reduce(data))), len(str(min_reduce(data)))) format = '%' + str(max_str_len) + 'd' format_function = lambda x: _formatInteger(x, format) - elif issubclass(dtype, _nt.floating): - if issubclass(dtype, _nt.longfloat): + elif issubclass(dtypeobj, _nt.floating): + if issubclass(dtypeobj, _nt.longfloat): format_function = _longfloatFormatter(precision) else: format = _floatFormat(data, precision, suppress_small) format_function = lambda x: _formatFloat(x, format) - elif issubclass(dtype, _nt.complexfloating): - if issubclass(dtype, _nt.clongfloat): + elif issubclass(dtypeobj, _nt.complexfloating): + if issubclass(dtypeobj, _nt.clongfloat): format_function = _clongfloatFormatter(precision) else: real_format = _floatFormat( @@ -169,13 +169,13 @@ def _array2string(a, max_line_width, precision, suppress_small, separator=' ', data.imag, precision, suppress_small, sign=1) format_function = lambda x: \ _formatComplex(x, real_format, imag_format) - elif issubclass(dtype, _nt.unicode_) or \ - issubclass(dtype, _nt.string_): + elif issubclass(dtypeobj, _nt.unicode_) or \ + issubclass(dtypeobj, _nt.string_): format = "%s" format_function = lambda x: repr(x) else: format = '%s' - format_function = lambda x: format % str(x) + format_function = lambda x: str(x) next_line_prefix = " " # skip over "[" next_line_prefix += " "*len(prefix) # skip over array( -- cgit v1.2.1