def _check_same_dim(self, dim: int, attr: str, name: str):
    dim_data = getattr(self, attr)
    if (dim != dim_data):
        raise ValueError('Cannot assign {0} with {1}={2}: data has {1}={3}'.format(name, attr, dim, dim_data))
def _check_same_dim(self, dim: int, attr: str, name: str):
    dim_data = getattr(self, attr)
    if (dim != dim_data):
        raise ValueError('Cannot assign {0} with {1}={2}: data has {1}={3}'.format(name, attr, dim, dim_data))