From 5ff2bffdbf5ef59f533ee0fae9780235c15aacf3 Mon Sep 17 00:00:00 2001 From: Chris Richardson Date: Mon, 8 Jan 2024 11:13:07 +0000 Subject: [PATCH 1/2] Remove some implicit PETSc from tests when not needed --- python/test/unit/fem/test_dof_permuting.py | 4 ++-- python/test/unit/fem/test_function.py | 6 +++--- python/test/unit/fem/test_function_space.py | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/test/unit/fem/test_dof_permuting.py b/python/test/unit/fem/test_dof_permuting.py index 95d03f7c871..5d913de2116 100644 --- a/python/test/unit/fem/test_dof_permuting.py +++ b/python/test/unit/fem/test_dof_permuting.py @@ -255,7 +255,7 @@ def test_evaluation(cell_type, space_type, space_order): for d in dofs: v = Function(V) - v.vector[:] = [1 if i == d else 0 for i in range(v.vector.local_size)] + v.x.array[:] = [1 if i == d else 0 for i in range(v.x.index_map.size_local)] values0 = v.eval(eval_points, [0 for i in eval_points]) values1 = v.eval(eval_points, [1 for i in eval_points]) if len(eval_points) == 1: @@ -303,7 +303,7 @@ def test_integral(cell_type, space_type, space_order): tdim = mesh.topology.dim for d in dofs: v = Function(V) - v.vector[:] = [1 if i == d else 0 for i, _ in enumerate(v.vector[:])] + v.x.array[:] = [1 if i == d else 0 for i, _ in enumerate(v.x.array[:])] if space_type in ["RT", "BDM", "RTCF", "NCF", "BDMCF", "AAF"]: # Hdiv def normal(x): diff --git a/python/test/unit/fem/test_function.py b/python/test/unit/fem/test_function.py index 04110374128..8cd38518b17 100644 --- a/python/test/unit/fem/test_function.py +++ b/python/test/unit/fem/test_function.py @@ -165,9 +165,9 @@ def f(x): w = Function(W) w.interpolate(f) - x = w.vector - assert x.max()[1] == 3.0 # /NOSONAR - assert x.min()[1] == 1.0 # /NOSONAR + x = w.x.array + assert x.max() == 3.0 # /NOSONAR + assert x.min() == 1.0 # /NOSONAR num_vertices = W.mesh.topology.index_map(0).size_global assert round(w.x.norm(la.Norm.l1) - 6 * num_vertices, 7) == 0 diff --git a/python/test/unit/fem/test_function_space.py b/python/test/unit/fem/test_function_space.py index 22b38c0f297..a4ff21fa9d8 100644 --- a/python/test/unit/fem/test_function_space.py +++ b/python/test/unit/fem/test_function_space.py @@ -177,7 +177,7 @@ def test_collapse(W, V): f_0 = Function(Ws[0][0]) f_1 = Function(V) - assert f_0.vector.getSize() == f_1.vector.getSize() + assert f_0.x.index_map.size_global == f_1.x.index_map.size_global def test_argument_equality(mesh, V, V2, W, W2): From aeb3852fc0730f53ba04a7b246d39e3c723528ea Mon Sep 17 00:00:00 2001 From: Chris Richardson Date: Mon, 8 Jan 2024 12:14:29 +0000 Subject: [PATCH 2/2] Another example --- python/test/unit/fem/test_quadrature_elements.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/test/unit/fem/test_quadrature_elements.py b/python/test/unit/fem/test_quadrature_elements.py index aad819db657..f4b6469dc32 100644 --- a/python/test/unit/fem/test_quadrature_elements.py +++ b/python/test/unit/fem/test_quadrature_elements.py @@ -147,7 +147,7 @@ def test_vector_element(shape): q_ = ufl.TestFunction(Quad) dq = ufl.TrialFunction(Quad) one = dolfinx.fem.Function(Quad) - one.vector.set(1.0) + one.x.array[:] = 1.0 mass_L_form = dolfinx.fem.form(ufl.inner(one, q_) * dx_m) mass_v = dolfinx.fem.assemble_vector(mass_L_form) mass_a_form = dolfinx.fem.form(ufl.inner(dq, q_) * dx_m)