diff --git a/python/test/unit/graph/test_adjacencylist.py b/python/test/unit/graph/test_adjacencylist.py index 55165acc3b2..a5bb77fb5a0 100644 --- a/python/test/unit/graph/test_adjacencylist.py +++ b/python/test/unit/graph/test_adjacencylist.py @@ -18,3 +18,11 @@ def test_create_adj2d(dtype): assert np.array_equal( adj.offsets, np.arange(0, num_nodes * num_links + num_links, num_links, dtype=np.int32) ) + + data = np.arange(20, dtype=dtype) + offsets = np.array([0, 5, 15, 20], dtype=np.int32) + adj = adjacencylist(data, offsets) + assert adj.num_nodes == 3 + assert len(adj.links(0)) == 5 + assert len(adj.links(1)) == 10 + assert len(adj.links(2)) == 5 diff --git a/python/test/unit/la/test_matrix_csr.py b/python/test/unit/la/test_matrix_csr.py index be44d27d8ff..f9345dc3510 100644 --- a/python/test/unit/la/test_matrix_csr.py +++ b/python/test/unit/la/test_matrix_csr.py @@ -144,6 +144,19 @@ def test_distributed_csr(dtype): assert np.isclose(mat.data.sum(), pre_final_sum) +@pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) +def test_set_block_matrix(dtype): + mesh_dtype = np.real(dtype(0)).dtype + ghost_mode = GhostMode.shared_facet + mesh = create_unit_square(MPI.COMM_WORLD, 2, 4, ghost_mode=ghost_mode, dtype=mesh_dtype) + V = fem.functionspace(mesh, ("Lagrange", 1, (2,))) + u, v = ufl.TrialFunction(V), ufl.TestFunction(V) + a = fem.form(ufl.inner(u, v) * ufl.dx, dtype=dtype) + A = fem.create_matrix(a) + As = A.to_scipy(ghosted=True) + assert As.blocksize == (2, 2) + + @pytest.mark.parametrize("dtype", [np.float32, np.float64, np.complex64, np.complex128]) def test_set_diagonal_distributed(dtype): mesh_dtype = np.real(dtype(0)).dtype