def test_cosmo_change(): """Can we change the cosmology settings. """ from sherpa.astro import xspec old_h0, old_q0, old_l0 = xspec.get_xscosmo() new_h0 = 51.0 new_q0 = 0.2 new_l0 = 0.48 if old_h0 == pytest.approx(new_h0): new_h0 -= 10.0 if old_q0 == pytest.approx(new_q0): new_q0 -= 0.05 if old_l0 == pytest.approx(new_l0): new_l0 += 0.01 try: xspec.set_xscosmo(new_h0, new_q0, new_l0) nval_h0, nval_q0, nval_l0 = xspec.get_xscosmo() finally: xspec.set_xscosmo(old_h0, old_q0, old_l0) assert nval_h0 == pytest.approx(new_h0) assert nval_q0 == pytest.approx(new_q0) assert nval_l0 == pytest.approx(new_l0)
def test_cosmo_default(): """Check the expected default setting for the cosmology settings. Ideally this test would be run before any other tests of XSPEC are made (i.e. any XSPEC code is called). """ from sherpa.astro import xspec oval = xspec.get_xscosmo() # Since this is a tuple of numbers, check individually assert len(oval) == 3 assert oval[0] == pytest.approx(DEFAULT_COSMO[0]) assert oval[1] == pytest.approx(DEFAULT_COSMO[1]) assert oval[2] == pytest.approx(DEFAULT_COSMO[2])