@@ -93,14 +93,51 @@ def test_exception_on_no_valid_files(tmp_path: Path) -> None:
9393 # Write a tiff file without metadata
9494 height = 10
9595 width = 10
96- arr = np .zeros ((height , width , 1 ), dtype = np .uint16 )
96+ arr = np .zeros ((1 , height , width ), dtype = np .uint16 )
9797 path_no_metadata = Path (tmp_path ) / "tiff_no_metadata.tiff"
9898 imwrite (path_no_metadata , arr , metadata = None , description = None , software = None , datetime = None )
9999
100100 with pytest .raises (ValueError , match = "No valid files were found" ):
101101 macsima (tmp_path )
102102
103103
104+ @pytest .mark .parametrize (
105+ "dimensions,expected" ,
106+ [
107+ (((10 , 10 ), (10 , 10 )), False ),
108+ (((10 , 10 ), (15 , 10 )), True ),
109+ (((10 , 10 ), (10 , 15 )), True ),
110+ (((15 , 10 ), (10 , 15 )), True ),
111+ ],
112+ )
113+ def test_check_differing_dimensions_works (dimensions : tuple [tuple [int , int ], tuple [int , int ]], expected : bool ) -> None :
114+ imgs = []
115+ for img_dim in dimensions :
116+ arr = da .from_array (np .ones ((1 , img_dim [0 ], img_dim [1 ]), dtype = np .uint16 ))
117+ imgs .append (arr )
118+
119+ if expected :
120+ with pytest .warns (UserWarning , match = "Supplied images have different dimensions!" ):
121+ assert MultiChannelImage ._check_for_differing_xy_dimensions (imgs ) == expected
122+ else :
123+ assert MultiChannelImage ._check_for_differing_xy_dimensions (imgs ) == expected
124+
125+
126+ def test_padding_on_differing_dimensions () -> None :
127+ heights = [10 , 10 , 15 , 20 ]
128+ widths = [10 , 15 , 10 , 20 ]
129+
130+ imgs = []
131+ for height , width in zip (heights , widths , strict = True ):
132+ arr = da .from_array (np .ones ((1 , height , width ), dtype = np .uint16 ))
133+ imgs .append (arr )
134+
135+ with pytest .warns (UserWarning , match = "Padding images with 0s to same size of \\ (20, 20\\ )" ):
136+ imgs_padded = MultiChannelImage ._pad_images (imgs )
137+ for img in imgs_padded :
138+ assert img .shape == (1 , 20 , 20 )
139+
140+
104141@skip_if_below_python_version ()
105142@pytest .mark .parametrize (
106143 "dataset,expected" ,
0 commit comments