def _protect_mask(mask):
    """ Boolean masks with length 1 may give a problem in the following syntax:
    array[mask] = 2 * array[mask]. Replace [True] by 0 and return None when
    the operation should be skipped."""
    if mask.size == 0:
        return None  # []
    elif mask.size > 1:
        return mask  # mask with len > 1
    if mask.ravel()[0]:
        return 0     # [True]
    else:
        return None