def selftestrun(argdict):

    outdir = argdict.get("-outdir")
    if outdir is None:
        outdir = pjoin("Validation", argdict['-ts'] + str(argdict.get('-ms-method')))
        argdict['-outdir'] = outdir

    arglist, _, _ = mm.argdict2list(argdict)

    mm.cleandir(outdir)
    flag = mm.run_driver(arglist, outdir)

    try:
        data = mm.parse_trace_file(pjoin(outdir, "trace"))
    except IOError:
        data = None

    return data, outdir, flag
def test_vs_implicit(argdict):

    implicit_dir = "validata"
    implicit_data = mm.parse_trace_file(pjoin(implicit_dir, "trace"))
    maxerrortol = 1e-3

    data, outdir, flag = selftestrun(argdict)

    if flag != 0:
        fail_message(outdir)
        return False

    mx_diffs = implicit_data['mean_mxs'] - data['mean_mxs']
    my_diffs = implicit_data['mean_mys'] - data['mean_mys']
    mz_diffs = implicit_data['mean_mzs'] - data['mean_mzs']

    maxerror = max(it.chain(mx_diffs, my_diffs, mz_diffs))

    if maxerror > maxerrortol:
        fail_message(outdir, maxerror)
        return False
    else:
        pass_message(outdir)
        return True