From b5c456e84dc87521a476ff51e3a2ab55f8c5c29f Mon Sep 17 00:00:00 2001 From: Simon Conseil Date: Tue, 1 Dec 2015 23:35:31 +0100 Subject: Allow to change the maximum width with a class variable. --- numpy/ma/core.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'numpy') diff --git a/numpy/ma/core.py b/numpy/ma/core.py index 3c1f8210d..5ef76a66e 100644 --- a/numpy/ma/core.py +++ b/numpy/ma/core.py @@ -2684,6 +2684,8 @@ class MaskedArray(ndarray): _defaultmask = nomask _defaulthardmask = False _baseclass = ndarray + # Maximum number of elements per axis used when printing an array. + _print_width = 100 def __new__(cls, data=None, mask=nomask, dtype=None, copy=False, subok=True, ndmin=0, fill_value=None, @@ -3712,14 +3714,14 @@ class MaskedArray(ndarray): if names is None: data = self._data mask = m - nval = 50 # For big arrays, to avoid a costly conversion to the # object dtype, extract the corners before the conversion. for axis in range(self.ndim): - if data.shape[axis] > 2 * nval: - arr = np.split(data, (nval, -nval), axis=axis) + if data.shape[axis] > self._print_width: + ind = np.int(self._print_width / 2) + arr = np.split(data, (ind, -ind), axis=axis) data = np.concatenate((arr[0], arr[2]), axis=axis) - arr = np.split(mask, (nval, -nval), axis=axis) + arr = np.split(mask, (ind, -ind), axis=axis) mask = np.concatenate((arr[0], arr[2]), axis=axis) res = data.astype("O") res.view(ndarray)[mask] = f -- cgit v1.2.1