@@ -132,6 +132,31 @@ async def test_open_group_unspecified_version(
132132 assert g2 .metadata .zarr_format == zarr_format
133133
134134
135+ @pytest .mark .parametrize ("store" , ["local" , "memory" , "zip" ], indirect = ["store" ])
136+ @pytest .mark .parametrize ("n_args" , [2 , 1 , 0 ])
137+ @pytest .mark .parametrize ("n_kwargs" , [2 , 1 , 0 ])
138+ def test_save (store : Store , n_args : int , n_kwargs : int ) -> None :
139+ data = np .arange (10 )
140+ if n_kwargs == 0 and n_args == 0 :
141+ with pytest .raises (ValueError ):
142+ save (store )
143+ return
144+ args = [np .arange (10 ) for _ in range (n_args )]
145+ kwargs = {f"arg_{ i } " : data for i in range (n_kwargs )}
146+ save (store , * args , ** kwargs )
147+ # open arrays
148+ if n_args == 1 and n_kwargs == 0 :
149+ a = open (store )
150+ assert isinstance (a , Array )
151+ assert_array_equal (a , data )
152+ else :
153+ g = open (store )
154+ assert isinstance (g , Group )
155+ for a in g .array_values ():
156+ assert_array_equal (a , data )
157+ assert g .nmembers () == n_args + n_kwargs
158+
159+
135160def test_save_errors () -> None :
136161 with pytest .raises (ValueError ):
137162 # no arrays provided
@@ -145,7 +170,7 @@ def test_save_errors() -> None:
145170 with pytest .raises (TypeError ):
146171 # mode is no valid argument and would get handled as an array
147172 a = np .arange (10 )
148- zarr .save (' data/example.zarr' , a , mode = 'w' )
173+ zarr .save (" data/example.zarr" , a , mode = "w" )
149174
150175
151176def test_open_with_mode_r (tmp_path : pathlib .Path ) -> None :
0 commit comments