Coverage for nilearn/surface/tests/test_utils.py: 0%
18 statements
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-16 12:32 +0200
« prev ^ index » next coverage.py v7.9.1, created at 2025-06-16 12:32 +0200
1import numpy as np
2import pytest
4from nilearn.surface import PolyData
5from nilearn.surface.utils import (
6 assert_polydata_equal,
7 assert_surface_mesh_equal,
8)
11def test_assert_polydata_equal():
12 """Check that PolyData with different keys are detected."""
13 data_1 = PolyData(left=np.ones((3, 2)), right=np.ones((3, 2)))
14 data_2 = PolyData(left=np.ones((3, 2)), right=np.ones((3, 2)))
16 assert_polydata_equal(data_1, data_2)
18 data_2.parts["new_key"] = np.ones((3, 2))
20 with pytest.raises(
21 ValueError, match="PolyData do not have the same keys."
22 ):
23 assert_polydata_equal(data_1, data_2)
26def test_assert_surface_mesh_equal(surf_mesh):
27 """Check that Meshes with different faces/coords are detected."""
28 assert_surface_mesh_equal(surf_mesh.parts["left"], surf_mesh.parts["left"])
30 with pytest.raises(
31 ValueError, match="Meshes do not have the same coordinates."
32 ):
33 assert_surface_mesh_equal(
34 surf_mesh.parts["left"], surf_mesh.parts["right"]
35 )
37 surf_mesh.parts["right"].coordinates = surf_mesh.parts["left"].coordinates
39 with pytest.raises(ValueError, match="Meshes do not have the same faces."):
40 assert_surface_mesh_equal(
41 surf_mesh.parts["left"], surf_mesh.parts["right"]
42 )