summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Conseil <contact@saimon.org>2015-12-01 23:35:31 +0100
committerSimon Conseil <contact@saimon.org>2015-12-01 23:35:31 +0100
commitb5c456e84dc87521a476ff51e3a2ab55f8c5c29f (patch)
tree4bb4a85c93a1aba1d19dda4fdf0e042d5df13af4
parent593345a75fdd3de103e3e50969fbca2ed752f08d (diff)
downloadnumpy-b5c456e84dc87521a476ff51e3a2ab55f8c5c29f.tar.gz
Allow to change the maximum width with a class variable.
-rw-r--r--numpy/ma/core.py10
1 files changed, 6 insertions, 4 deletions
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