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))
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
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)
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)
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)