@@ -610,6 +610,7 @@ def test_image_mem_reopen_noop():
610610 assert np .array_equal (rimg , img )
611611
612612
613+ @pytest .mark .parametrize ("nan_value" , [np .nan , np .inf , - np .inf ])
613614@pytest .mark .parametrize ("dtype" , [np .float32 , np .float64 ])
614615@pytest .mark .parametrize (
615616 "fname" ,
@@ -618,9 +619,17 @@ def test_image_mem_reopen_noop():
618619 "mem://" ,
619620 ],
620621)
621- def test_image_compression_nulls (fname , dtype ):
622+ def test_image_compression_nulls (fname , dtype , nan_value ):
622623 data = np .arange (36 ).reshape ((6 , 6 )).astype (dtype )
623- data [1 , 1 ] = np .nan
624+ data [1 , 1 ] = nan_value
625+
626+ # everything comes back as nan
627+ if nan_value is not np .nan :
628+ msk = ~ np .isfinite (data )
629+ cdata = data .copy ()
630+ cdata [msk ] = np .nan
631+ else :
632+ cdata = data
624633
625634 with tempfile .TemporaryDirectory () as tmpdir :
626635 if "mem://" not in fname :
@@ -629,20 +638,26 @@ def test_image_compression_nulls(fname, dtype):
629638 fpth = fname
630639
631640 with FITS (fpth , "rw" ) as fits :
632- fits .write (data , compress = 'RICE_1' , tile_dims = (3 , 3 ))
641+ fits .write (
642+ data ,
643+ compress = 'RICE_1' ,
644+ tile_dims = (3 , 3 ),
645+ dither_seed = 10 ,
646+ qlevel = 2 ,
647+ )
633648 read_data = fits [1 ].read ()
634649
635650 np .testing .assert_allclose (
636651 read_data ,
637- data ,
652+ cdata ,
638653 )
639654
640655 if "mem://" not in fpth :
641656 with FITS (fpth , "r" ) as fits :
642657 read_data = fits [1 ].read ()
643658 np .testing .assert_allclose (
644659 read_data ,
645- data ,
660+ cdata ,
646661 )
647662
648663
0 commit comments