@@ -224,85 +224,85 @@ def test_array_write_read(self):
224224 flcarr_f64 = FlacArray .from_array (inputf64 , mpi_comm = self .comm , use_threads = True )
225225 check_f64 = None
226226
227- # tmpdir = None
228- # tmppath = None
229- # if rank == 0:
230- # tmpdir = tempfile.TemporaryDirectory()
231- # tmppath = tmpdir.name
232- # if self.comm is not None:
233- # tmppath = self.comm.bcast(tmppath, root=0)
234-
235- # i32_file = os.path.join(tmppath, "data_i32.zarr")
236- # with ZarrGroup(i32_file, mode="w", comm=self.comm) as zf:
237- # flcarr_i32.write_zarr(zf)
238- # if self.comm is not None:
239- # self.comm.barrier()
240- # with ZarrGroup(i32_file, mode="r", comm=self.comm) as zf:
241- # check_i32 = FlacArray.read_zarr(zf, mpi_comm=self.comm)
242-
243- # i64_file = os.path.join(tmppath, "data_i64.zarr")
244- # with ZarrGroup(i64_file, mode="w", comm=self.comm) as zf:
245- # flcarr_i64.write_zarr(zf)
246- # if self.comm is not None:
247- # self.comm.barrier()
248- # with ZarrGroup(i64_file, mode="r", comm=self.comm) as zf:
249- # check_i64 = FlacArray.read_zarr(zf, mpi_comm=self.comm)
250-
251- # f32_file = os.path.join(tmppath, "data_f32.zarr")
252- # with ZarrGroup(f32_file, mode="w", comm=self.comm) as zf:
253- # flcarr_f32.write_zarr(zf)
254- # if self.comm is not None:
255- # self.comm.barrier()
256- # with ZarrGroup(f32_file, mode="r", comm=self.comm) as zf:
257- # check_f32 = FlacArray.read_zarr(zf, mpi_comm=self.comm)
258-
259- # f64_file = os.path.join(tmppath, "data_f64.zarr")
260- # with ZarrGroup(f64_file, mode="w", comm=self.comm) as zf:
261- # flcarr_f64.write_zarr(zf)
262- # if self.comm is not None:
263- # self.comm.barrier()
264- # with ZarrGroup(f64_file, mode="r", comm=self.comm) as zf:
265- # check_f64 = FlacArray.read_zarr(zf, mpi_comm=self.comm)
266-
267- # if self.comm is not None:
268- # self.comm.barrier()
269- # del tmppath
270- # del tmpdir
271-
272- # if check_i32 != flcarr_i32:
273- # print(f"check_i32 = {check_i32}", flush=True)
274- # print(f"flcarr_i32 = {flcarr_i32}", flush=True)
275- # print("FAIL on i32 roundtrip to zarr", flush=True)
276- # self.assertTrue(False)
277- # else:
278- # output_i32 = check_i32.to_array()
279- # if not np.array_equal(output_i32, input32):
280- # print("FAIL on i32 zarr decompressed array check", flush=True)
281- # self.assertTrue(False)
282-
283- # if check_i64 != flcarr_i64:
284- # print("FAIL on i64 roundtrip to zarr", flush=True)
285- # self.assertTrue(False)
286- # else:
287- # output_i64 = check_i64.to_array()
288- # if not np.array_equal(output_i64, input64):
289- # print("FAIL on i64 zarr decompressed array check", flush=True)
290- # self.assertTrue(False)
291-
292- # if check_f32 != flcarr_f32:
293- # print("FAIL on f32 roundtrip to zarr", flush=True)
294- # self.assertTrue(False)
295- # else:
296- # output_f32 = check_f32.to_array()
297- # if not np.allclose(output_f32, inputf32, rtol=1.0e-5, atol=1.0e-5):
298- # print("FAIL on f32 zarr decompressed array check", flush=True)
299- # self.assertTrue(False)
300-
301- # if check_f64 != flcarr_f64:
302- # print("FAIL on f64 roundtrip to zarr", flush=True)
303- # self.assertTrue(False)
304- # else:
305- # output_f64 = check_f64.to_array()
306- # if not np.allclose(output_f64, inputf64, rtol=1.0e-5, atol=1.0e-5):
307- # print("FAIL on f64 zarr decompressed array check", flush=True)
308- # self.assertTrue(False)
227+ tmpdir = None
228+ tmppath = None
229+ if rank == 0 :
230+ tmpdir = tempfile .TemporaryDirectory ()
231+ tmppath = tmpdir .name
232+ if self .comm is not None :
233+ tmppath = self .comm .bcast (tmppath , root = 0 )
234+
235+ i32_file = os .path .join (tmppath , "data_i32.zarr" )
236+ with ZarrGroup (i32_file , mode = "w" , comm = self .comm ) as zf :
237+ flcarr_i32 .write_zarr (zf )
238+ if self .comm is not None :
239+ self .comm .barrier ()
240+ with ZarrGroup (i32_file , mode = "r" , comm = self .comm ) as zf :
241+ check_i32 = FlacArray .read_zarr (zf , mpi_comm = self .comm )
242+
243+ i64_file = os .path .join (tmppath , "data_i64.zarr" )
244+ with ZarrGroup (i64_file , mode = "w" , comm = self .comm ) as zf :
245+ flcarr_i64 .write_zarr (zf )
246+ if self .comm is not None :
247+ self .comm .barrier ()
248+ with ZarrGroup (i64_file , mode = "r" , comm = self .comm ) as zf :
249+ check_i64 = FlacArray .read_zarr (zf , mpi_comm = self .comm )
250+
251+ f32_file = os .path .join (tmppath , "data_f32.zarr" )
252+ with ZarrGroup (f32_file , mode = "w" , comm = self .comm ) as zf :
253+ flcarr_f32 .write_zarr (zf )
254+ if self .comm is not None :
255+ self .comm .barrier ()
256+ with ZarrGroup (f32_file , mode = "r" , comm = self .comm ) as zf :
257+ check_f32 = FlacArray .read_zarr (zf , mpi_comm = self .comm )
258+
259+ f64_file = os .path .join (tmppath , "data_f64.zarr" )
260+ with ZarrGroup (f64_file , mode = "w" , comm = self .comm ) as zf :
261+ flcarr_f64 .write_zarr (zf )
262+ if self .comm is not None :
263+ self .comm .barrier ()
264+ with ZarrGroup (f64_file , mode = "r" , comm = self .comm ) as zf :
265+ check_f64 = FlacArray .read_zarr (zf , mpi_comm = self .comm )
266+
267+ if self .comm is not None :
268+ self .comm .barrier ()
269+ del tmppath
270+ del tmpdir
271+
272+ if check_i32 != flcarr_i32 :
273+ print (f"check_i32 = { check_i32 } " , flush = True )
274+ print (f"flcarr_i32 = { flcarr_i32 } " , flush = True )
275+ print ("FAIL on i32 roundtrip to zarr" , flush = True )
276+ self .assertTrue (False )
277+ else :
278+ output_i32 = check_i32 .to_array ()
279+ if not np .array_equal (output_i32 , input32 ):
280+ print ("FAIL on i32 zarr decompressed array check" , flush = True )
281+ self .assertTrue (False )
282+
283+ if check_i64 != flcarr_i64 :
284+ print ("FAIL on i64 roundtrip to zarr" , flush = True )
285+ self .assertTrue (False )
286+ else :
287+ output_i64 = check_i64 .to_array ()
288+ if not np .array_equal (output_i64 , input64 ):
289+ print ("FAIL on i64 zarr decompressed array check" , flush = True )
290+ self .assertTrue (False )
291+
292+ if check_f32 != flcarr_f32 :
293+ print ("FAIL on f32 roundtrip to zarr" , flush = True )
294+ self .assertTrue (False )
295+ else :
296+ output_f32 = check_f32 .to_array ()
297+ if not np .allclose (output_f32 , inputf32 , rtol = 1.0e-5 , atol = 1.0e-5 ):
298+ print ("FAIL on f32 zarr decompressed array check" , flush = True )
299+ self .assertTrue (False )
300+
301+ if check_f64 != flcarr_f64 :
302+ print ("FAIL on f64 roundtrip to zarr" , flush = True )
303+ self .assertTrue (False )
304+ else :
305+ output_f64 = check_f64 .to_array ()
306+ if not np .allclose (output_f64 , inputf64 , rtol = 1.0e-5 , atol = 1.0e-5 ):
307+ print ("FAIL on f64 zarr decompressed array check" , flush = True )
308+ self .assertTrue (False )
0 commit comments