Exemplo n.º 1
0
def test_pickle_io_traditionalgraph():
    G = build_graph(data, knn=5, decay=10, thresh=0)
    with tempfile.TemporaryDirectory() as tempdir:
        path = os.path.join(tempdir, "tmp.pkl")
        G.to_pickle(path)
        G_prime = graphtools.read_pickle(path)
    assert isinstance(G_prime, type(G))
Exemplo n.º 2
0
def test_pickle_io_pygspgraph():
    G = build_graph(data, knn=5, decay=None, use_pygsp=True)
    with tempfile.TemporaryDirectory() as tempdir:
        path = os.path.join(tempdir, "tmp.pkl")
        G.to_pickle(path)
        G_prime = graphtools.read_pickle(path)
    assert isinstance(G_prime, type(G))
    assert G_prime.logger.name == G.logger.name
Exemplo n.º 3
0
def test_pickle_bad_pickle():
    import pickle

    with tempfile.TemporaryDirectory() as tempdir:
        path = os.path.join(tempdir, "tmp.pkl")
        with open(path, "wb") as f:
            pickle.dump("hello world", f)
        G = graphtools.read_pickle(path)
Exemplo n.º 4
0
def test_pickle_bad_pickle():
    with assert_warns_message(
            UserWarning,
            "Returning object that is not a graphtools.base.BaseGraph"):
        with tempfile.TemporaryDirectory() as tempdir:
            path = os.path.join(tempdir, "tmp.pkl")
            with open(path, "wb") as f:
                pickle.dump("hello world", f)
            G = graphtools.read_pickle(path)
Exemplo n.º 5
0
def test_pickle_io_landmarkgraph():
    G = build_graph(data, knn=5, decay=None, n_landmark=data.shape[0] // 2)
    L = G.landmark_op
    with tempfile.TemporaryDirectory() as tempdir:
        path = os.path.join(tempdir, "tmp.pkl")
        G.to_pickle(path)
        G_prime = graphtools.read_pickle(path)
    assert isinstance(G_prime, type(G))
    np.testing.assert_array_equal(L, G_prime._landmark_op)