Skip to content

Commit 107ead6

Browse files
committed
TEST: More fully test mesh and family APIs
1 parent cbb91d1 commit 107ead6

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

nibabel/tests/test_pointset.py

+31-1
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def test_to_mask(self):
186186

187187

188188
class TestTriangularMeshes:
189-
def test_init(self):
189+
def test_api(self):
190190
# Tetrahedron
191191
coords = np.array(
192192
[
@@ -227,6 +227,36 @@ def test_init(self):
227227
assert tm2.n_triangles == 4
228228
assert tm3.n_triangles == 4
229229

230+
out_coords, out_tris = tm1.get_mesh()
231+
# Currently these are the exact arrays, but I don't think we should
232+
# bake that assumption into the tests
233+
assert np.allclose(out_coords, coords)
234+
assert np.allclose(out_tris, triangles)
235+
236+
237+
class TestCoordinateFamilyMixin(TestPointsets):
238+
def test_names(self):
239+
coords = np.array(
240+
[
241+
[0.0, 0.0, 0.0],
242+
[0.0, 0.0, 1.0],
243+
[0.0, 1.0, 0.0],
244+
[1.0, 0.0, 0.0],
245+
]
246+
)
247+
cfm = ps.CoordinateFamilyMixin(coords)
248+
249+
assert cfm.get_names() == ['original']
250+
assert np.allclose(cfm.with_name('original').coordinates, coords)
251+
252+
cfm.add_coordinates('shifted', coords + 1)
253+
assert cfm.get_names() == ['original', 'shifted']
254+
shifted = cfm.with_name('shifted')
255+
assert np.allclose(shifted.coordinates, coords + 1)
256+
assert shifted.get_names() == ['original', 'shifted']
257+
original = shifted.with_name('original')
258+
assert np.allclose(original.coordinates, coords)
259+
230260

231261
class H5ArrayProxy:
232262
def __init__(self, file_like, dataset_name):

0 commit comments

Comments
 (0)