'This ensures that a masked array is returned if self is masked.'

def __array_prepare__(self, array, context=None):

    if (self.mask is not None):
        return np.ma.masked_array(array, self.mask)
    else:
        return array
