# helpers

def instance_check(instance, expected_type):
    if not isinstance(instance, expected_type):
        raise TypeError(f"Expected instance of type {expected_type}, got {type(instance)}")
    
def shape_check(array, expected_shape):
    if array.shape != expected_shape:
        raise ValueError(f"Expected shape {expected_shape}, got {array.shape}")

def dimension_check(array, expected_dim):
    if array.ndim != expected_dim:
        raise ValueError(f"Expected {expected_dim} dimensions, got {array.ndim}")
    
def size_check(array, expected_size):
    if array.size != expected_size:
        raise ValueError(f"Expected size {expected_size}, got {array.size}")
    
def non_empty_check(array):
    if array.size == 0:
        raise ValueError("Array cannot be empty")