

def _compare(a, b):
    global last_keys
    skip_types = ['whitener', 'proj', 'reginv', 'noisenorm', 'nchan', 'command_line', 'working_dir', 'mri_file', 'mri_id']
    try:
        if isinstance(a, (dict, Info)):
            assert_true(isinstance(b, (dict, Info)))
            for (k, v) in six.iteritems(a):
                if ((k not in b) and (k not in skip_types)):
                    raise ValueError(("First one had one second one didn't:\n%s not in %s" % (k, b.keys())))
                if (k not in skip_types):
                    last_keys.pop()
                    last_keys = ([k] + last_keys)
                    _compare(v, b[k])
            for (k, v) in six.iteritems(b):
                if ((k not in a) and (k not in skip_types)):
                    raise ValueError(("Second one had one first one didn't:\n%s not in %s" % (k, a.keys())))
        elif isinstance(a, list):
            assert_true((len(a) == len(b)))
            for (i, j) in zip(a, b):
                _compare(i, j)
        elif isinstance(a, sparse.csr.csr_matrix):
            assert_array_almost_equal(a.data, b.data)
            assert_equal(a.indices, b.indices)
            assert_equal(a.indptr, b.indptr)
        elif isinstance(a, np.ndarray):
            assert_array_almost_equal(a, b)
        else:
            assert_true((a == b))
    except Exception as exptn:
        print(last_keys)
        raise exptn

dataset/ETHPy150Open mne-tools/mne-python/mne/minimum_norm/tests/test_inverse.py _compare/original