@@ -195,12 +195,13 @@ def test_create_array_defaults(store: Store):
195195        )
196196
197197
198- @pytest .mark .parametrize ("array_order" , ["C" , "F" ]) 
199- @pytest .mark .parametrize ("data_order" , ["C" , "F" ]) 
200- @pytest .mark .parametrize ("memory_order" , ["C" , "F" ]) 
201- def  test_v2_non_contiguous (
202-     array_order : Literal ["C" , "F" ], data_order : Literal ["C" , "F" ], memory_order : Literal ["C" , "F" ]
203- ) ->  None :
198+ @pytest .mark .parametrize ("numpy_order" , ["C" , "F" ]) 
199+ @pytest .mark .parametrize ("zarr_order" , ["C" , "F" ]) 
200+ def  test_v2_non_contiguous (numpy_order : Literal ["C" , "F" ], zarr_order : Literal ["C" , "F" ]) ->  None :
201+     """ 
202+     Make sure zarr v2 arrays save data using the memory order given to the zarr array, 
203+     not the memory order of the original numpy array. 
204+     """ 
204205    store  =  MemoryStore ()
205206    arr  =  zarr .create_array (
206207        store ,
@@ -212,26 +213,27 @@ def test_v2_non_contiguous(
212213        filters = None ,
213214        compressors = None ,
214215        overwrite = True ,
215-         order = array_order ,
216-         config = {"order" : memory_order },
216+         order = zarr_order ,
217217    )
218218
219-     # Non-contiguous write 
220-     a  =  np .arange (arr .shape [0 ] *  arr .shape [1 ]).reshape (arr .shape , order = data_order )
219+     # Non-contiguous write, using numpy memory order  
220+     a  =  np .arange (arr .shape [0 ] *  arr .shape [1 ]).reshape (arr .shape , order = numpy_order )
221221    arr [6 :9 , 3 :6 ] =  a [6 :9 , 3 :6 ]  # The slice on the RHS is important 
222222    np .testing .assert_array_equal (arr [6 :9 , 3 :6 ], a [6 :9 , 3 :6 ])
223223
224224    np .testing .assert_array_equal (
225225        a [6 :9 , 3 :6 ],
226226        np .frombuffer (
227227            sync (store .get ("2.1" , default_buffer_prototype ())).to_bytes (), dtype = "float64" 
228-         ).reshape ((3 , 3 ), order = array_order ),
228+         ).reshape ((3 , 3 ), order = zarr_order ),
229229    )
230-     if  memory_order  ==  "F" :
230+     # After writing and reading from zarr array, order should be same as zarr order 
231+     if  zarr_order  ==  "F" :
231232        assert  (arr [6 :9 , 3 :6 ]).flags .f_contiguous 
232233    else :
233234        assert  (arr [6 :9 , 3 :6 ]).flags .c_contiguous 
234235
236+     # Contiguous write 
235237    store  =  MemoryStore ()
236238    arr  =  zarr .create_array (
237239        store ,
@@ -243,18 +245,17 @@ def test_v2_non_contiguous(
243245        compressors = None ,
244246        filters = None ,
245247        overwrite = True ,
246-         order = array_order ,
247-         config = {"order" : memory_order },
248+         order = zarr_order ,
248249    )
249250
250-     # Contiguous write 
251-     a  =  np .arange (9 ).reshape ((3 , 3 ), order = data_order )
252-     if  data_order  ==  "F" :
253-         assert  a .flags .f_contiguous 
254-     else :
255-         assert  a .flags .c_contiguous 
251+     a  =  np .arange (9 ).reshape ((3 , 3 ), order = numpy_order )
256252    arr [6 :9 , 3 :6 ] =  a 
257253    np .testing .assert_array_equal (arr [6 :9 , 3 :6 ], a )
254+     # After writing and reading from zarr array, order should be same as zarr order 
255+     if  zarr_order  ==  "F" :
256+         assert  (arr [6 :9 , 3 :6 ]).flags .f_contiguous 
257+     else :
258+         assert  (arr [6 :9 , 3 :6 ]).flags .c_contiguous 
258259
259260
260261def  test_default_compressor_deprecation_warning ():
0 commit comments