def test_dynamic_graph_discrete_signal_real(): snapshot_count = 250 n_count = 100 feature_count = 32 edge_indices, edge_weights, features = generate_signal(250, 100, 32) targets = [np.random.uniform(0,10,(n_count,)) for _ in range(snapshot_count)] dataset = DynamicGraphTemporalSignal(edge_indices, edge_weights, features, targets) for epoch in range(2): for snapshot in dataset: assert snapshot.edge_index.shape[0] == 2 assert snapshot.edge_index.shape[1] == snapshot.edge_attr.shape[0] assert snapshot.x.shape == (100, 32) assert snapshot.y.shape == (100, ) targets = [np.floor(np.random.uniform(0,10,(n_count,))).astype(int) for _ in range(snapshot_count)] dataset = DynamicGraphTemporalSignal(edge_indices, edge_weights, features, targets) for epoch in range(2): for snapshot in dataset: assert snapshot.edge_index.shape[0] == 2 assert snapshot.edge_index.shape[1] == snapshot.edge_attr.shape[0] assert snapshot.x.shape == (100, 32) assert snapshot.y.shape == (100, )
def test_discrete_train_test_split_dynamic(): snapshot_count = 250 n_count = 100 feature_count = 32 edge_indices, edge_weights, features = generate_signal(250, 100, 32) targets = [ np.random.uniform(0, 10, (n_count, )) for _ in range(snapshot_count) ] dataset = DynamicGraphTemporalSignal(edge_indices, edge_weights, features, targets) train_dataset, test_dataset = temporal_signal_split(dataset, 0.8) for epoch in range(2): for snapshot in test_dataset: assert snapshot.edge_index.shape[0] == 2 assert snapshot.edge_index.shape[1] == snapshot.edge_attr.shape[0] assert snapshot.x.shape == (100, 32) assert snapshot.y.shape == (100, ) for epoch in range(2): for snapshot in train_dataset: assert snapshot.edge_index.shape[0] == 2 assert snapshot.edge_index.shape[1] == snapshot.edge_attr.shape[0] assert snapshot.x.shape == (100, 32) assert snapshot.y.shape == (100, )
def test_dynamic_graph_discrete_signal(): dataset = DynamicGraphTemporalSignal([None, None], [None, None], [None, None],[None, None]) for snapshot in dataset: assert snapshot.edge_index is None assert snapshot.edge_attr is None assert snapshot.x is None assert snapshot.y is None
def test_dynamic_graph_temporal_signal_additional_attrs(): dataset = DynamicGraphTemporalSignal([None], [None], [None], [None], optional1=[np.array([1])], optional2=[np.array([2])]) assert dataset.additional_feature_keys == ["optional1", "optional2"] for snapshot in dataset: assert snapshot.optional1.shape == (1, ) assert snapshot.optional2.shape == (1, )