def test_ibis8542model_save(ibis8542model_results, ibis8542model_resultsobjs, tmp_path): # Testing mcalf.models.FitResults.save method res1, m = ibis8542model_results[:2] results10, results11 = ibis8542model_resultsobjs(res1) tmp10 = os.path.join(tmp_path, "ibis8542model_fit_save_results10.fits") results10.save(tmp10, m) tmp11 = os.path.join(tmp_path, "ibis8542model_fit_save_results11.fits") results11.save(tmp11, m) diff_kwargs = { 'ignore_keywords': ['CHECKSUM', 'DATASUM', 'VERSION'], 'atol': 1e-6, 'rtol': 1e-5, # 1e-6 was failing at results10 CHI2[2, 2] on macOS CI env (but nowhere else) } for saved, truth in [(tmp10, "ibis8542model_fit_results10.fits"), (tmp11, "ibis8542model_fit_results11.fits")]: saved = fits.open(saved) truth = fits.open(data_path(truth)) diff = fits.FITSDiff(saved, truth, **diff_kwargs) if not diff.identical: # If this fails tolerances *may* need to be adjusted fits.printdiff(saved, truth, **diff_kwargs) raise ValueError( f"{saved.filename()} and {truth.filename()} differ")
def test_printdiff(self): """ Test that FITSDiff can run the different inputs without crashing. """ # Testing different string input options assert printdiff(self.data('arange.fits'), self.data('blank.fits')) is None assert printdiff(self.data('arange.fits'), self.data('blank.fits'), ext=0) is None assert printdiff(self.data('o4sp040b0_raw.fits'), self.data('o4sp040b0_raw.fits'), extname='sci') is None # This may seem weird, but check printdiff to see, need to test # incorrect second file with pytest.raises(OSError): printdiff('o4sp040b0_raw.fits', 'fakefile.fits', extname='sci') # Test HDU object inputs with fits.open(self.data('stddata.fits'), mode='readonly') as in1: with fits.open(self.data('checksum.fits'), mode='readonly') as in2: assert printdiff(in1[0], in2[0]) is None with pytest.raises(ValueError): printdiff(in1[0], in2[0], ext=0) assert printdiff(in1, in2) is None with pytest.raises(NotImplementedError): printdiff(in1, in2, 0)