Skip to content

Commit 4028cf3

Browse files
authored
Merge pull request #20 from scientificcomputing/finsberg/fixes-for-conda
Fixes for conda
2 parents b2bcc5a + 6eec766 commit 4028cf3

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

tests/conftest.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def backend(request):
4141
def cluster():
4242
cluster = ipp.Cluster(engines="mpi", n=2)
4343
rc = cluster.start_and_connect_sync()
44+
rc.wait_for_engines(n=2)
4445
yield rc
4546
cluster.stop_cluster_sync()
4647

tests/test_legacy_readers.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import numpy as np
1515
import pytest
1616
import ufl
17-
from dolfinx.fem.petsc import LinearProblem
1817

1918
from io4dolfinx import (
2019
read_cell_data,
@@ -110,6 +109,11 @@ def test_legacy_function(backend):
110109
f = ufl.conditional(ufl.gt(x[0], 0.5), x[1], 2 * x[0])
111110
L = ufl.inner(f, v) * ufl.dx
112111

112+
if not dolfinx.has_petsc4py:
113+
pytest.skip("dolfinx not configured with PETSc4py")
114+
115+
from dolfinx.fem.petsc import LinearProblem
116+
113117
uh = dolfinx.fem.Function(V)
114118
if "petsc_options_prefix" in inspect.signature(LinearProblem.__init__).parameters.keys():
115119
extra_options = {"petsc_options_prefix": "legacy_test"}
@@ -139,6 +143,8 @@ def test_read_legacy_function_from_checkpoint(backend):
139143
if not path.exists():
140144
pytest.skip(f"{path} does not exist")
141145

146+
from dolfinx.fem.petsc import LinearProblem
147+
142148
mesh = read_mesh_from_legacy_h5(path, comm, "/Mesh/mesh", backend=backend)
143149

144150
V = dolfinx.fem.functionspace(mesh, ("DG", 2))
@@ -149,6 +155,9 @@ def test_read_legacy_function_from_checkpoint(backend):
149155
f = ufl.conditional(ufl.gt(x[0], 0.5), x[1], 2 * x[0])
150156
L = ufl.inner(f, v) * ufl.dx
151157

158+
if not dolfinx.has_petsc4py:
159+
pytest.skip("dolfinx not configured with PETSc4py")
160+
152161
uh = dolfinx.fem.Function(V)
153162
if "petsc_options_prefix" in inspect.signature(LinearProblem.__init__).parameters.keys():
154163
extra_options = {"petsc_options_prefix": "legacy_checkpoint_test"}

tests/test_vtkhdf.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def test_write_point_data(dtype, tmp_path, cell_type):
105105
filename=filename, name="u", mesh=grid, time=tj, backend="vtkhdf"
106106
)
107107
v_ref = Function(u.function_space, dtype=u.x.array.dtype)
108-
atol = 10 * np.finfo(u.x.array.dtype).eps
108+
atol = 15 * np.finfo(u.x.array.dtype).eps
109109
v_ref.interpolate(lambda x: f(x, tj))
110110
np.testing.assert_allclose(u.x.array, v_ref.x.array, atol=atol)
111111

@@ -124,7 +124,7 @@ def test_write_point_data(dtype, tmp_path, cell_type):
124124
filename=blocked_file, name="u", mesh=grid, time=tk, backend="vtkhdf"
125125
)
126126
v_ref = Function(u.function_space, dtype=u.x.array.dtype)
127-
atol = 10 * np.finfo(u.x.array.dtype).eps
127+
atol = 15 * np.finfo(u.x.array.dtype).eps
128128
v_ref.interpolate(lambda x: g(x, tk))
129129
np.testing.assert_allclose(u.x.array, v_ref.x.array, atol=atol)
130130

@@ -160,7 +160,7 @@ def test_write_cell_data(dtype, tmp_path, cell_type):
160160
filename=filename, name="u", mesh=grid, time=tj, backend="vtkhdf"
161161
)
162162
v_ref = Function(u.function_space, dtype=u.x.array.dtype)
163-
atol = 10 * np.finfo(u.x.array.dtype).eps
163+
atol = 15 * np.finfo(u.x.array.dtype).eps
164164
v_ref.interpolate(lambda x: f(x, tj))
165165
np.testing.assert_allclose(u.x.array, v_ref.x.array, atol=atol)
166166

@@ -179,7 +179,7 @@ def test_write_cell_data(dtype, tmp_path, cell_type):
179179
filename=blocked_file, name="u", mesh=grid, time=tk, backend="vtkhdf"
180180
)
181181
v_ref = Function(u.function_space, dtype=u.x.array.dtype)
182-
atol = 10 * np.finfo(u.x.array.dtype).eps
182+
atol = 15 * np.finfo(u.x.array.dtype).eps
183183
v_ref.interpolate(lambda x: g(x, tk))
184184
np.testing.assert_allclose(u.x.array, v_ref.x.array, atol=atol)
185185

@@ -254,7 +254,7 @@ def test_write_meshtags(dtype, tmp_path, generate_reference_map):
254254
)
255255
org_maps[dim] = generate_reference_map(mesh, et, comm, root)
256256

257-
tol = 10 * np.finfo(dtype).eps
257+
tol = 15 * np.finfo(dtype).eps
258258
# Read in hex grid from second time step
259259
hex_mesh = io4dolfinx.read_mesh(
260260
filename, comm, time=1.0, backend_args={"name": "hex"}, backend="vtkhdf"
@@ -288,7 +288,7 @@ def test_write_meshtags(dtype, tmp_path, generate_reference_map):
288288

289289
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
290290
def test_read_write_pointdata(dtype, tmp_path):
291-
tol = 10 * np.finfo(dtype).eps
291+
tol = 15 * np.finfo(dtype).eps
292292

293293
comm = MPI.COMM_WORLD
294294
tmp_path = comm.bcast(tmp_path, root=0)
@@ -360,7 +360,7 @@ def f(x, t):
360360

361361
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
362362
def test_read_write_celldata(dtype, tmp_path):
363-
tol = 10 * np.finfo(dtype).eps
363+
tol = 15 * np.finfo(dtype).eps
364364

365365
comm = MPI.COMM_WORLD
366366
tmp_path = comm.bcast(tmp_path, root=0)
@@ -436,7 +436,7 @@ def f(x, t):
436436

437437
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
438438
def test_read_write_mix_data(dtype, tmp_path):
439-
tol = 10 * np.finfo(dtype).eps
439+
tol = 15 * np.finfo(dtype).eps
440440

441441
mesh = create_unit_square(MPI.COMM_WORLD, 5, 7, dtype=dtype)
442442

0 commit comments

Comments
 (0)