Skip to content

Commit

Permalink
TEST: More fully test mesh and family APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
effigies committed Sep 22, 2023
1 parent cbb91d1 commit 107ead6
Showing 1 changed file with 31 additions and 1 deletion.
32 changes: 31 additions & 1 deletion nibabel/tests/test_pointset.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ def test_to_mask(self):


class TestTriangularMeshes:
def test_init(self):
def test_api(self):
# Tetrahedron
coords = np.array(
[
Expand Down Expand Up @@ -227,6 +227,36 @@ def test_init(self):
assert tm2.n_triangles == 4
assert tm3.n_triangles == 4

out_coords, out_tris = tm1.get_mesh()
# Currently these are the exact arrays, but I don't think we should
# bake that assumption into the tests
assert np.allclose(out_coords, coords)
assert np.allclose(out_tris, triangles)


class TestCoordinateFamilyMixin(TestPointsets):
def test_names(self):
coords = np.array(
[
[0.0, 0.0, 0.0],
[0.0, 0.0, 1.0],
[0.0, 1.0, 0.0],
[1.0, 0.0, 0.0],
]
)
cfm = ps.CoordinateFamilyMixin(coords)

assert cfm.get_names() == ['original']
assert np.allclose(cfm.with_name('original').coordinates, coords)

cfm.add_coordinates('shifted', coords + 1)
assert cfm.get_names() == ['original', 'shifted']
shifted = cfm.with_name('shifted')
assert np.allclose(shifted.coordinates, coords + 1)
assert shifted.get_names() == ['original', 'shifted']
original = shifted.with_name('original')
assert np.allclose(original.coordinates, coords)


class H5ArrayProxy:
def __init__(self, file_like, dataset_name):
Expand Down

0 comments on commit 107ead6

Please sign in to comment.