def test_omni_matrix_ones_zeros(): # Should get all ones n_graphs = [2, 5, 10] # Test for different number of graphs for n in n_graphs: ones = [np.ones((10, 10)) for _ in range(n)] expected_output = np.ones((10 * n, 10 * n)) output = _get_omni_matrix(ones) assert array_equal(output, expected_output) zeros = [np.zeros((10, 10)) for _ in range(n)] expected_output = np.zeros((10 * n, 10 * n)) output = _get_omni_matrix(zeros) assert array_equal(output, expected_output)
def test_omni_matrix_symmetric(): np.random.seed(3) n = 15 p = 0.4 n_graphs = [2, 5, 10] for n in n_graphs: graphs = [er_np(n, p) for _ in range(n)] output = _get_omni_matrix(graphs) assert is_symmetric(output)
def test_omni_matrix_random(): expected_output = np.array([ [0.0, 1.0, 1.0, 0.0, 0.5, 0.5], [1.0, 0.0, 1.0, 0.5, 0.0, 1.0], [1.0, 1.0, 0.0, 0.5, 1.0, 0.0], [0.0, 0.5, 0.5, 0.0, 0.0, 0.0], [0.5, 0.0, 1.0, 0.0, 0.0, 1.0], [0.5, 1.0, 0.0, 0.0, 1.0, 0.0], ]) np.random.seed(4) graphs = [er_np(3, 0.5) for _ in range(2)] A = _get_omni_matrix(graphs) assert_allclose(A, expected_output)
def test_omni_matrix_random(): expected_output = np.array([ [0.0, 1.0, 1.0, 0.0, 0.5, 0.5], [1.0, 0.0, 1.0, 0.5, 0.0, 1.0], [1.0, 1.0, 0.0, 0.5, 1.0, 0.0], [0.0, 0.5, 0.5, 0.0, 0.0, 0.0], [0.5, 0.0, 1.0, 0.0, 0.0, 1.0], [0.5, 1.0, 0.0, 0.0, 1.0, 0.0], ]) np.random.seed(4) dat_list = ( [[0.0, 1.0, 1.0], [1.0, 0.0, 1.0], [1.0, 1.0, 0.0]], [[0.0, 0.0, 0.0], [0.0, 0.0, 1.0], [0.0, 1.0, 0.0]], ) graphs = np.array(dat_list) A = _get_omni_matrix(graphs) assert_allclose(A, expected_output)