def test_standardize(self): spA = SparseGraph(self.A) spA.standardize() resA = sp.csr_matrix( np.array([[0., 0., 1., 0., 0.], [0., 0., 1., 0., 1.], [1., 1., 0., 1., 0.], [0., 0., 1., 0., 1.], [0., 1., 0., 1., 0.]])) assert np.allclose(spA.adj_matrix.A, resA.A)
def test_standardize_edgeattrs(self): edge_attrs = np.array([0, 1, 2, 3, 1, 5, 6, 7, 8]) spA = SparseGraph(self.A, edge_attr_matrix=edge_attrs) spA.standardize() resA = sp.csr_matrix( np.array([[0., 0., 1., 0., 0.], [0., 0., 1., 0., 1.], [1., 1., 0., 1., 0.], [0., 0., 1., 0., 1.], [0., 1., 0., 1., 0.]])) res_edge_attrs = np.array([1, 3, 8, 1, 3, 6, 6, 7, 8, 7]) assert np.allclose(spA.adj_matrix.A, resA.A) assert np.allclose(spA.edge_attr_matrix, res_edge_attrs)