From 8d4a974b81d02c092e72531095e642a4e6154a17 Mon Sep 17 00:00:00 2001 From: Philipp Diercks Date: Mon, 14 Aug 2023 14:45:29 +0200 Subject: [PATCH] [boundary.show_marked] exclude function from coverage; remove tests depending on matplotlib --- .../boundary_conditions/boundary.py | 4 +- .../test_boundary_show_marked.py | 39 ------------------- 2 files changed, 2 insertions(+), 41 deletions(-) delete mode 100644 tests/boundary_conditions/test_boundary_show_marked.py diff --git a/src/fenicsxconcrete/boundary_conditions/boundary.py b/src/fenicsxconcrete/boundary_conditions/boundary.py index 056f65f..b41f2db 100644 --- a/src/fenicsxconcrete/boundary_conditions/boundary.py +++ b/src/fenicsxconcrete/boundary_conditions/boundary.py @@ -167,7 +167,7 @@ def show_marked( domain: dolfinx.mesh.Mesh, marker: Callable, filename: str | None = None, -) -> None: +) -> None: # pragma: no cover """Shows dof coordinates marked by `marker`. Notes: @@ -207,7 +207,7 @@ def show_marked( if filename is not None: plt.savefig(filename) else: - plt.show() # pragma: no cover + plt.show() def to_floats(x: typing.Iterable[int] | typing.Iterable[float]) -> list[float]: diff --git a/tests/boundary_conditions/test_boundary_show_marked.py b/tests/boundary_conditions/test_boundary_show_marked.py deleted file mode 100644 index 05e9a94..0000000 --- a/tests/boundary_conditions/test_boundary_show_marked.py +++ /dev/null @@ -1,39 +0,0 @@ -import pathlib -import tempfile - -import dolfinx -import numpy as np -import pytest -from mpi4py import MPI - -from fenicsxconcrete.boundary_conditions.boundary import show_marked - - -def everywhere(x: np.ndarray) -> np.ndarray: - return np.full(x[0].shape, True, dtype=bool) - - -def unit_interval() -> dolfinx.mesh.Mesh: - return dolfinx.mesh.create_unit_interval(MPI.COMM_SELF, 10) - - -def unit_cube() -> dolfinx.mesh.Mesh: - return dolfinx.mesh.create_unit_cube(MPI.COMM_SELF, 2, 2, 2) - - -def test_write_fig() -> None: - with tempfile.NamedTemporaryFile(suffix=".png") as tf: - domain = dolfinx.mesh.create_unit_square(MPI.COMM_SELF, 5, 5) - show_marked(domain, everywhere, filename=tf.name) - assert pathlib.Path(tf.name).exists() - - -@pytest.mark.parametrize("domain", [unit_interval(), unit_cube()]) -def test_tdim(domain: dolfinx.mesh.Mesh) -> None: - with pytest.raises(NotImplementedError): - show_marked(domain, everywhere) - - -if __name__ == "__main__": - test_write_fig() - test_tdim()