Skip to content

Commit

Permalink
Add testing for reading VTK format files
Browse files Browse the repository at this point in the history
  • Loading branch information
jni committed Dec 22, 2016
1 parent abd62de commit bdaf054
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/test_imio.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,19 @@ def test_cremi_roundtrip():
f.close()
np.testing.assert_equal(stored_resolution, (40, 4, 4))
np.testing.assert_equal(raw_in, raw_image)
np.testing.assert_equal(lab_in, labels)
np.testing.assert_equal(lab_in, labels)


def test_vtk_roundtrip():
for i in range(4):
ar_shape = np.random.randint(1, 50, size=3)
dtypes = list(imio.numpy_type_to_vtk_string.keys())
cur_dtype = np.random.choice(dtypes)
if np.issubdtype(cur_dtype, np.integer):
ar = np.random.randint(0, 127, size=ar_shape).astype(cur_dtype)
else:
ar = np.random.rand(*ar_shape).astype(cur_dtype)
with temporary_file('.vtk') as fout:
imio.write_vtk(ar, fout)
ar_in = imio.read_vtk(fout)
np.testing.assert_equal(ar, ar_in)

0 comments on commit bdaf054

Please sign in to comment.