The mask array must be the same shape as the source array. The shape of the result array must be obtained from the shape of the source array by deleting dimension dim (see section 4.4).