def concatenate(arrays, axis=<NUM_LIT:0>):
d = np.concatenate([getdata(a) for a in arrays], axis)<EOL>rcls = get_masked_subclass(*arrays)<EOL>data = d.view(rcls)<EOL>for x in arrays:<EOL><INDENT>if getmask(x) is not nomask:<EOL><INDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>return data<EOL><DEDENT>dm = np.concatenate([getmaskarray(a) for a in arrays], axis)<EOL><INDENT>shrink = numpy.logical_or.reduce([getattr(a,'<STR_LIT>',True) for a in arrays])<EOL>if shrink and not dm.any():<EOL><DEDENT>if not dm.dtype.fields and not dm.any():<EOL><INDENT>data._mask = nomask<EOL><DEDENT>else:<EOL><INDENT>data._mask = dm.reshape(d.shape)<EOL><DEDENT>return data<EOL>
Concatenate a sequence of arrays along the given axis.

Parameters
----------
arrays : sequence of array_like
    The arrays must have the same shape, except in the dimension
    corresponding to `axis` (the first, by default).
axis : int, optional
    The axis along which the arrays will be joined. Default is 0.

Returns
-------
result : MaskedArray
    The concatenated array with any masked entries preserved.

See Also
--------
numpy.concatenate : Equivalent function in the top-level NumPy module.

Examples
--------
>>> import numpy.ma as ma
>>> a = ma.arange(3)
>>> a[1] = ma.masked
>>> b = ma.arange(2, 5)
>>> a
masked_array(data = [0 -- 2],
             mask = [False  True False],
       fill_value = 999999)
>>> b
masked_array(data = [2 3 4],
             mask = False,
       fill_value = 999999)
>>> ma.concatenate([a, b])
masked_array(data = [0 -- 2 2 3 4],
             mask = [False  True False False False False],
       fill_value = 999999)