diff options
author | Mark Wiebe <mwwiebe@gmail.com> | 2011-08-15 17:38:54 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-08-27 07:26:54 -0600 |
commit | c6261dbb99ad4125284a89e879786b114dddb39b (patch) | |
tree | dffb7f66a210eb7d2b1a4c60b9a35fee0a1adfca /numpy/core/arrayprint.py | |
parent | c7c080a72d05b3ec0cb93ab4f724f8b65ebf63c3 (diff) | |
download | numpy-c6261dbb99ad4125284a89e879786b114dddb39b.tar.gz |
ENH: missingdata: Make arr.item() and arr.itemset() work with NA masks
Diffstat (limited to 'numpy/core/arrayprint.py')
-rw-r--r-- | numpy/core/arrayprint.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py index 1d072fe5d..506cce8cc 100644 --- a/numpy/core/arrayprint.py +++ b/numpy/core/arrayprint.py @@ -430,16 +430,20 @@ def array2string(a, max_line_width=None, precision=None, if a.shape == (): x = a.item() - try: - lst = a._format(x) - msg = "The `_format` attribute is deprecated in Numpy 2.0 and " \ - "will be removed in 2.1. Use the `formatter` kw instead." - import warnings - warnings.warn(msg, DeprecationWarning) - except AttributeError: - if isinstance(x, tuple): - x = _convert_arrays(x) - lst = style(x) + if isna(x): + lst = str(x) + else: + try: + lst = a._format(x) + msg = "The `_format` attribute is deprecated in Numpy " \ + "2.0 and will be removed in 2.1. Use the " \ + "`formatter` kw instead." + import warnings + warnings.warn(msg, DeprecationWarning) + except AttributeError: + if isinstance(x, tuple): + x = _convert_arrays(x) + lst = style(x) elif reduce(product, a.shape) == 0: # treat as a null array if any of shape elements == 0 lst = "[]" |