Skip to content

Commit

Permalink
Fix import errors
Browse files Browse the repository at this point in the history
  • Loading branch information
ampdes committed Aug 16, 2024
1 parent 64480e2 commit 61a8288
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
11 changes: 3 additions & 8 deletions python/demo/demo_checkpointing.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,12 @@
#

# +
import importlib.util
import os

if importlib.util.find_spec("adios2") is not None:
import dolfinx
import dolfinx

if not dolfinx.has_adios2:
print("This demo requires DOLFINx to be compiled with ADIOS2 enabled.")
exit(0)
else:
print("This demo requires ADIOS2.")
if not dolfinx.common.has_adios2:
print("This demo requires DOLFINx to be compiled with ADIOS2 enabled.")
exit(0)

from mpi4py import MPI
Expand Down
4 changes: 3 additions & 1 deletion python/test/unit/io/test_adios2.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
from dolfinx import default_real_type, default_scalar_type
from dolfinx.fem import Function, assemble_scalar, form, functionspace
from dolfinx.graph import adjacencylist
from dolfinx.io import ADIOS2, read_mesh, write_mesh
from dolfinx.mesh import CellType, GhostMode, create_mesh, create_unit_cube, create_unit_square


Expand Down Expand Up @@ -47,6 +46,9 @@ def generate_mesh(dim: int, simplex: bool, N: int = 5, dtype=None):
@pytest.mark.parametrize("dim", [2, 3])
@pytest.mark.parametrize("simplex", [True, False])
def test_mesh_read_write(encoder, suffix, ghost_mode, dtype, dim, simplex, tmp_path):
"Test writing of a mesh"
from dolfinx.io import ADIOS2, read_mesh, write_mesh

N = 5
# Consistent tmp dir across processes
fname = MPI.COMM_WORLD.bcast(tmp_path, root=0)
Expand Down
6 changes: 3 additions & 3 deletions python/test/unit/io/test_xdmf_meshtags.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# SPDX-License-Identifier: LGPL-3.0-or-later

from pathlib import Path
from xml.etree import ElementTree
from xml.etree import ElementTree as ET

from mpi4py import MPI

Expand Down Expand Up @@ -93,8 +93,8 @@ def test_3d(tempdir, cell_type, encoding):
facets_local = comm.allreduce(
(mt.indices < mesh.topology.index_map(2).size_local).sum(), op=MPI.SUM
)
parser = ElementTree.XMLParser()
tree = ElementTree.parse(Path(tempdir, "meshtags_3d_out.xdmf"), parser)
parser = ET.XMLParser()
tree = ET.parse(Path(tempdir, "meshtags_3d_out.xdmf"), parser)
num_lines = int(tree.findall(".//Grid[@Name='lines']/Topology")[0].get("NumberOfElements"))
num_facets = int(tree.findall(".//Grid[@Name='facets']/Topology")[0].get("NumberOfElements"))
assert num_lines == lines_local
Expand Down

0 comments on commit 61a8288

Please sign in to comment.