@@ -746,6 +746,44 @@ def test_resize_2d(store: MemoryStore, zarr_format: ZarrFormat) -> None:
746746 assert new_shape == z [:].shape
747747
748748
749+ @pytest .mark .parametrize ("store" , ["local" ], indirect = True )
750+ @pytest .mark .parametrize ("open" , ["open" , "open_array" ])
751+ def test_append_config_passed (store : LocalStore , open : str , zarr_format : ZarrFormat ) -> None :
752+ z = zarr .create_array (
753+ store = store ,
754+ name = "test" ,
755+ shape = (2 ,),
756+ dtype = int ,
757+ fill_value = 0 ,
758+ chunks = (1 ,),
759+ config = {"write_empty_chunks" : True },
760+ overwrite = True ,
761+ zarr_format = zarr_format ,
762+ )
763+ z [:] = 0
764+ print (store )
765+
766+ def assert_correct_files_written (expected : list [str ]) -> None :
767+ """Helper to compare written files"""
768+ if zarr_format == 2 :
769+ actual = [f .name for f in store .root .rglob ("test/*" )]
770+ else :
771+ actual = [f .name for f in store .root .rglob ("test/c/*" )]
772+ actual = [f for f in actual if f not in [".zattrs" , ".zarray" , "zarr.json" ]]
773+ assert sorted (expected ) == sorted (actual )
774+
775+ assert_correct_files_written (["0" , "1" ])
776+
777+ # parametrized over open and open_array
778+ z = getattr (zarr , open )(store , path = "test" , config = {"write_empty_chunks" : True }, fill_value = 0 )
779+ z .resize ((4 ,))
780+ assert_correct_files_written (["0" , "1" ])
781+ z [2 :] = 0
782+ assert_correct_files_written (["0" , "1" , "2" , "3" ])
783+ z [:] = 0
784+ assert_correct_files_written (["0" , "1" , "2" , "3" ])
785+
786+
749787@pytest .mark .parametrize ("store" , ["memory" ], indirect = True )
750788def test_append_1d (store : MemoryStore , zarr_format : ZarrFormat ) -> None :
751789 a = np .arange (105 )
0 commit comments