diff options
author | Mark Wiebe <mwiebe@enthought.com> | 2011-07-26 11:58:43 -0500 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-08-27 07:26:47 -0600 |
commit | 0cc2e75cd160c44dba1dbcadfb530cfbe7d0cf98 (patch) | |
tree | bfd16498af4e50a9f70378737d30402f314ed439 /numpy/core | |
parent | 5e6d038bf75ef6c436e620e54158194c5d16070c (diff) | |
download | numpy-0cc2e75cd160c44dba1dbcadfb530cfbe7d0cf98.tar.gz |
ENH: missingdata: Get printing of NAs to work a little bit better
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/arrayprint.py | 4 | ||||
-rw-r--r-- | numpy/core/numeric.py | 14 |
2 files changed, 14 insertions, 4 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 0786b2904..fcda825c7 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -583,7 +583,9 @@ class FloatFormat(object): import numeric as _nc err = _nc.seterr(invalid='ignore') try: - if isnan(x): + if isna(x): + return str(x) + elif isnan(x): if self.sign: return self.special_fmt % ('+' + _nan_str,) else: diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index f74b2548c..e073128dd 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -1324,14 +1324,22 @@ def array_repr(arr, max_line_width=None, precision=None, suppress_small=None): ', ', "array(") else: # show zero-length shape unless it is (0,) lst = "[], shape=%s" % (repr(arr.shape),) - typeless = arr.dtype.type in _typelessdata if arr.__class__ is not ndarray: cName= arr.__class__.__name__ else: cName = "array" - if typeless and arr.size: - return cName + "(%s)" % lst + + skiptype = (arr.dtype.type in _typelessdata) and arr.size > 0 + + if arr.flags.maskna: + lst += ", maskna=True" + # If everything is NA, can't skip the type + if np.all(np.isna(arr)): + skiptype = False + + if skiptype: + return "%s(%s)" % (cName, lst) else: typename = arr.dtype.name # Quote typename in the output if it is "complex". |