def ensure_same_shape(new_arg, old_arg):
    return """
    if (%(new_arg)s_dims[0] != %(old_arg)s_dims[0] ||
        %(new_arg)s_dims[1] != %(old_arg)s_dims[1] ||
        %(new_arg)s_dims[2] != %(old_arg)s_dims[2] ||
        %(new_arg)s_dims[3] != %(old_arg)s_dims[3]) {
        PyErr_SetString(PyExc_ValueError, "%%(class_name)s: %(new_arg)s "
                                          "must have same shape as "
                                          "%(old_arg)s");
        %%(fail)s;
    }
    """ % locals()
dataset/ETHPy150Open lisa-lab/pylearn2/pylearn2/sandbox/cuda_convnet/code_templates.py/ensure_same_shape/original