示例#1
0
def dummy_test(infile, expfile):

    # load input test data
    ifile = open(infile, "br")
    idic = pickle.load(ifile)
    ifile.close()

    slm = SLM(FixedEffect(1), FixedEffect(1))
    for key in idic.keys():
        setattr(slm, key, idic[key])

    resels_py, reselspvert_py, edg_py = compute_resels(slm)

    out = {}
    out["resels"] = resels_py
    out["reselspvert"] = reselspvert_py
    out["edg"] = edg_py

    # load expected outout data
    efile = open(expfile, "br")
    expdic = pickle.load(efile)
    efile.close()

    testout = []

    for key in out.keys():
        if out[key] is not None and expdic[key] is not None:
            comp = np.allclose(out[key],
                               expdic[key],
                               rtol=1e-05,
                               equal_nan=True)
            testout.append(comp)

    assert all(flag == True for (flag) in testout)
示例#2
0
def generate_random_slm(rand_dict):
    """Generates a valid SLM for a surface.
    Parameters
    ----------
    surf : BSPolyData or a dictionary with key 'tri'
        Brain surface.
    Returns
    -------
    brainstat.stats.SLM
        SLM object.
    """
    # this is going to be the input slm
    I = {}
    rand_slm = SLM(FixedEffect(1), FixedEffect(1))
    for key in rand_dict.keys():
        setattr(rand_slm, key, rand_dict[key])
        I[key] = rand_dict[key]

    # this is going to be the output dict
    O = {}
    O["resels"], O["reselspvert"], O["edg"] = compute_resels(rand_slm)

    return I, O