diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-10-23 20:45:19 -0700 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-10-23 21:09:07 -0700 |
commit | 6b41ba8623acc94aeb5e7fa5e8f8998e8630aabe (patch) | |
tree | 6b6de4ab7c2a741ebb406c34f8863d95c35ab9d6 | |
parent | e0c60faed08ed5f726a9566466f7c20c08255dee (diff) | |
download | numpy-6b41ba8623acc94aeb5e7fa5e8f8998e8630aabe.tar.gz |
MAINT: Separate stringification from masked_print_option-insertion
This means we can implement `__unicode__` easily too, or perhaps `__format__` in future
-rw-r--r-- | numpy/ma/core.py | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 66dbd7a8f..88ecfddc2 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -3833,10 +3833,10 @@ class MaskedArray(ndarray): _new._mask = _mask.compress(condition, axis=axis) return _new - def __str__(self): + def __insert_masked_print(self): """ - String representation. - + Replace masked values with masked_print_option, casting all innermost + dtypes to object. """ if masked_print_option.enabled(): mask = self._mask @@ -3862,7 +3862,10 @@ class MaskedArray(ndarray): _recursive_printoption(res, mask, masked_print_option) else: res = self.filled(self.fill_value) - return str(res) + return res + + def __str__(self): + return str(self.__insert_masked_print()) def __repr__(self): """ |