1- import numpy as np
1+ import pytest
22
3- from pynwb . base import Images , ImageReferences
3+ import numpy as np
44from pynwb .image import GrayscaleImage
55
66from nwbinspector import InspectorMessage , Importance
77from nwbinspector .checks .images import check_order_of_images_unique , check_order_of_images_len
88
9+ try :
10+ from pynwb .base import Images , ImageReferences
11+
12+ HAVE_IMAGES = True
13+ except ImportError :
14+ HAVE_IMAGES = False
15+ skip_reason = "You must have PyNWB>=v2.1.0 to run these tests!"
16+
917
18+ @pytest .mark .skipif (not HAVE_IMAGES , reason = skip_reason )
1019def test_check_order_of_images_unique ():
1120
1221 imgs = [GrayscaleImage (name = f"image{ i } " , data = np .random .randn (10 , 10 )) for i in range (5 )]
@@ -23,6 +32,7 @@ def test_check_order_of_images_unique():
2332 )
2433
2534
35+ @pytest .mark .skipif (not HAVE_IMAGES , reason = skip_reason )
2636def test_pass_check_order_of_images_unique ():
2737
2838 imgs = [GrayscaleImage (name = f"image{ i } " , data = np .random .randn (10 , 10 )) for i in range (5 )]
@@ -32,6 +42,7 @@ def test_pass_check_order_of_images_unique():
3242 assert check_order_of_images_unique (images ) is None
3343
3444
45+ @pytest .mark .skipif (not HAVE_IMAGES , reason = skip_reason )
3546def test_check_order_of_images_len ():
3647
3748 imgs = [GrayscaleImage (name = f"image{ i } " , data = np .random .randn (10 , 10 )) for i in range (5 )]
@@ -48,6 +59,7 @@ def test_check_order_of_images_len():
4859 )
4960
5061
62+ @pytest .mark .skipif (not HAVE_IMAGES , reason = skip_reason )
5163def test_pass_check_order_of_images_len ():
5264
5365 imgs = [GrayscaleImage (name = f"image{ i } " , data = np .random .randn (10 , 10 )) for i in range (5 )]
0 commit comments