diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-03-22 23:10:43 +0000 |
---|---|---|
committer | Eric Wieser <wieser.eric@gmail.com> | 2017-05-05 21:36:03 +0100 |
commit | e6b8e75547af0cc4d38af458eff5e5d6c14102b8 (patch) | |
tree | ddb9dc76e81382ccce6d7f5f28c2f558b3658fa5 /numpy/ma/extras.py | |
parent | 69b0c42bca27dd5d5522de306bcd7db7deccbfad (diff) | |
download | numpy-e6b8e75547af0cc4d38af458eff5e5d6c14102b8.tar.gz |
MAINT: Remove code duplicated from np.r_ in np.ma.mr_
Also adds a test for the disabled-by-design behaviour - this would return
raw matrices, not masked arrays
Diffstat (limited to 'numpy/ma/extras.py')
-rw-r--r-- | numpy/ma/extras.py | 55 |
1 files changed, 5 insertions, 50 deletions
diff --git a/numpy/ma/extras.py b/numpy/ma/extras.py index e100e471c..10b9634a3 100644 --- a/numpy/ma/extras.py +++ b/numpy/ma/extras.py @@ -1461,60 +1461,15 @@ class MAxisConcatenator(AxisConcatenator): mr_class """ - - def __init__(self, axis=0): - AxisConcatenator.__init__(self, axis, matrix=False) + concatenate = staticmethod(concatenate) def __getitem__(self, key): + # matrix builder syntax, like 'a, b; c, d' if isinstance(key, str): raise MAError("Unavailable for masked array.") - if not isinstance(key, tuple): - key = (key,) - objs = [] - scalars = [] - final_dtypedescr = None - for k in range(len(key)): - scalar = False - if isinstance(key[k], slice): - step = key[k].step - start = key[k].start - stop = key[k].stop - if start is None: - start = 0 - if step is None: - step = 1 - if isinstance(step, complex): - size = int(abs(step)) - newobj = np.linspace(start, stop, num=size) - else: - newobj = np.arange(start, stop, step) - elif isinstance(key[k], str): - if (key[k] in 'rc'): - self.matrix = True - self.col = (key[k] == 'c') - continue - try: - self.axis = int(key[k]) - continue - except (ValueError, TypeError): - raise ValueError("Unknown special directive") - elif type(key[k]) in np.ScalarType: - newobj = asarray([key[k]]) - scalars.append(k) - scalar = True - else: - newobj = key[k] - objs.append(newobj) - if isinstance(newobj, ndarray) and not scalar: - if final_dtypedescr is None: - final_dtypedescr = newobj.dtype - elif newobj.dtype > final_dtypedescr: - final_dtypedescr = newobj.dtype - if final_dtypedescr is not None: - for k in scalars: - objs[k] = objs[k].astype(final_dtypedescr) - res = concatenate(tuple(objs), axis=self.axis) - return self._retval(res) + + return super(MAxisConcatenator, self).__getitem__(key) + class mr_class(MAxisConcatenator): """ |