class NoBCArray(np.ndarray):

    def __new__(cls, input_array, info=None):
        obj = np.asarray(input_array).view(cls)
return obj

def __array_wrap__(self, out_arr, context=None):
    if self.shape != out_arr.shape:
        raise ValueError('Shape different')
return np.ndarray.__array_wrap__(self, out_arr, context)
a = NoBCArray([[1, 2]])
b = NoBCArray([[3], [4]])
a + b
How to prevent adding two arrays by broadcasting in numpy?