def check_convergence(datasets, expected_rate, tol=0.2):
    """For a set of convergence test check that the rate of convergence as dt
    and h -> 0 is as expected. dt and h are linked so it is enough to
    test only for dt.
    """

    rate = mm.convergence_rate(datasets, error_norm_norm=max)

    # Check if near to expected value
    ok = abs(rate - expected_rate) < tol

    # Print messages, identify by first dataset for simplicity.
    dataid = _default_label(datasets[0])
    if ok:
        mm.okprint("convergence rate", rate, "ok in", dataid)
    else:
        mm.badprint("convergence rate", rate,
                    "but expected", expected_rate, "+/-", tol,
                    "in", dataid)

    # ??ds check goodness of fit?

    return ok