def test_gap_x0(t, gap=1e-10): t = TreeInstance.load(test_dir(t)) x = t.solve().x alpha = t.dual assert np.isnan(alpha[t.root]) assert not np.isnan(alpha[:-1]).any() assert all(np.abs(alpha[:-1]) <= t.lam[:-1] + gap) assert min(t.gamma) >= -1e-12 assert max(t.gamma) < 1e-10
def test_tree5_write_h5_read(tree5): pytest.importorskip("toml") ti = tree5 ti.save('tree5.toml') t2 = TreeInstance.load('tree5.toml') assert repr(ti) == repr(t2), f"\n\n{ti}\n\n{t2}\n"
def tree1(): return TreeInstance.load(test_dir("tree0.1.toml"))
def test_tree5_write_h5_read(tree5): ti = tree5 ti.save('tree5.h5') t2 = TreeInstance.load('tree5.h5') assert repr(ti) == repr(t2), f"\n\n{ti}\n\n{t2}\n"