Skip to content

Commit 94bcd3f

Browse files
Add unittests for image helper functions
1 parent 16b308f commit 94bcd3f

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/test_image_helper.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import numpy as np
2+
3+
4+
def test_transform_input_image():
5+
from bioimageio.core.image_helper import transform_input_image
6+
7+
ax_list = ["yx", "xy", "cyx", "yxc", "bczyx", "xyz", "xyzc", "bzyxc"]
8+
im = np.random.rand(256, 256)
9+
for axes in ax_list:
10+
inp = transform_input_image(im, axes)
11+
assert inp.ndim == len(axes)
12+
13+
ax_list = ["zyx", "cyx", "yxc", "bczyx", "xyz", "xyzc", "bzyxc"]
14+
vol = np.random.rand(64, 64, 64)
15+
for axes in ax_list:
16+
inp = transform_input_image(vol, axes)
17+
assert inp.ndim == len(axes)
18+
19+
20+
def test_transform_output_tensor():
21+
from bioimageio.core.image_helper import transform_output_tensor
22+
23+
tensor = np.random.rand(1, 3, 64, 64, 64)
24+
tensor_axes = "bczyx"
25+
26+
out_ax_list = ["bczyx", "cyx", "xyc", "byxc", "zyx", "xyz"]
27+
for out_axes in out_ax_list:
28+
out = transform_output_tensor(tensor, tensor_axes, out_axes)
29+
assert out.ndim == len(out_axes)

0 commit comments

Comments
 (0)