@@ -652,38 +652,51 @@ def test_set_transform_fov(ch_shape_dtype, arr_name):
652652 ]
653653
654654
655- @given (
656- ch_shape_dtype = _channels_and_random_5d_shape_and_dtype (),
657- )
658- @settings (deadline = None )
659- def test_set_scale (ch_shape_dtype ):
655+ @pytest .mark .parametrize ("image_name" , ["0" , "1" , "a" , "*" ])
656+ def test_set_scale (image_name ):
660657 """Test `iohub.ngff.Position.set_scale()`"""
661- channel_names , shape , dtype = ch_shape_dtype
662- transform = [
663- TransformationMeta (type = "translation" , translation = (1 , 2 , 3 , 4 , 5 )),
664- TransformationMeta (type = "scale" , scale = (5 , 4 , 3 , 2 , 1 )),
665- ]
658+ translation = [float (t ) for t in range (1 , 6 )]
659+ scale = [float (s ) for s in range (5 , 0 , - 1 )]
660+ array_name = "0" if image_name == "*" else image_name
661+ new_scale = 10.0
666662 with TemporaryDirectory () as temp_dir :
667663 store_path = os .path .join (temp_dir , "ome.zarr" )
668664 with open_ome_zarr (
669- store_path , layout = "fov" , mode = "w-" , channel_names = channel_names
665+ store_path , layout = "fov" , mode = "w-" , channel_names = [ "a" , "b" ]
670666 ) as dataset :
671- dataset .create_zeros (name = "0" , shape = shape , dtype = dtype )
672- dataset . set_transform ( image = "0" , transform = transform )
673- dataset . set_scale ( image = "0" , axis_name = "z" , new_scale = 10.0 )
674- assert dataset . scale [ - 3 ] == 10.0
675- assert (
676- dataset . metadata . multiscales [ 0 ]
677- . datasets [ 0 ]
678- . coordinate_transformations [ 0 ]
679- . translation [ - 1 ]
680- == 5
667+ dataset .create_zeros (
668+ name = array_name ,
669+ shape = ( 1 , 2 , 4 , 8 , 16 ),
670+ dtype = int ,
671+ transform = [
672+ TransformationMeta (
673+ type = "translation" , translation = translation
674+ ),
675+ TransformationMeta ( type = "scale" , scale = scale ),
676+ ],
681677 )
682-
683678 with pytest .raises (ValueError ):
684- dataset .set_scale (image = "0" , axis_name = "z" , new_scale = - 1.0 )
685-
686- assert dataset .zattrs ["iohub" ]["prior_z_scale" ] == 3.0
679+ dataset .set_scale (
680+ image = image_name , axis_name = "z" , new_scale = - 1.0
681+ )
682+ with pytest .raises (KeyError ):
683+ dataset .set_scale (
684+ image = "nonexistent" , axis_name = "z" , new_scale = 9.0
685+ )
686+ assert dataset .scale [- 3 ] == 3.0
687+ dataset .set_scale (
688+ image = image_name , axis_name = "z" , new_scale = new_scale
689+ )
690+ if image_name == "*" :
691+ assert dataset .scale [- 3 ] == new_scale * 3.0
692+ else :
693+ assert dataset .scale [- 3 ] == new_scale
694+ assert dataset .get_effective_translation (array_name ) == translation
695+ for tf in dataset .zattrs ["iohub" ]["previous_transforms" ][0 ][
696+ "transforms"
697+ ]:
698+ if tf ["type" ] == "scale" :
699+ assert tf ["scale" ] == scale
687700
688701
689702@given (channel_names = channel_names_st )
0 commit comments