def test_list_ids(): session = Session() session.load_arrays(1, TEST, TEST) session.load_arrays("1", TEST, TEST2) # order of 1 and "1" is not determined assert {1, "1"} == set(session.list_data_ids()) assert_array_equal(TEST2, session.get_data('1').get_dep()) assert_array_equal(TEST, session.get_data(1).get_dep())
def test_bug_275(make_data_path): session = Session() session.load_data(make_data_path('3c273.pi')) str(session.get_data()) str(session.get_rmf()) str(session.get_arf()) session.load_data(make_data_path('img.fits')) str(session.get_data())
def test_list_ids(): session = Session() session.load_arrays(1, TEST, TEST) session.load_arrays("1", TEST, TEST2) # order of 1 and "1" is not determined assert {1, "1"} == set(session.list_data_ids()) assert_array_equal(TEST2, session.get_data('1').get_dep()) assert_array_equal(TEST, session.get_data(1).get_dep())
def test_bug_275(make_data_path): session = Session() session.load_data(make_data_path('3c273.pi')) str(session.get_data()) str(session.get_rmf()) str(session.get_arf()) session.load_data(make_data_path('img.fits')) str(session.get_data())
def test_save_restore(tmpdir): outfile = tmpdir.join("sherpa.save") session = Session() session.load_arrays(1, TEST, TEST2) session.save(str(outfile), clobber=True) session.clean() assert set() == set(session.list_data_ids()) session.restore(str(outfile)) assert {1, } == set(session.list_data_ids()) assert_array_equal(TEST, session.get_data(1).get_indep()[0]) assert_array_equal(TEST2, session.get_data(1).get_dep())
def test_save_restore(tmpdir): outfile = tmpdir.join("sherpa.save") session = Session() session.load_arrays(1, TEST, TEST2) session.save(str(outfile), clobber=True) session.clean() assert set() == set(session.list_data_ids()) session.restore(str(outfile)) assert { 1, } == set(session.list_data_ids()) assert_array_equal(TEST, session.get_data(1).get_indep()[0]) assert_array_equal(TEST2, session.get_data(1).get_dep())
def test_load_arrays_no_errors(data_no_errors): from sherpa.astro.ui.utils import Session session = Session() data = data_no_errors data_class = data.__class__ data_args = DATA_NO_ERRORS_ARGS args = data_args + (data_class, ) session.load_arrays(*args) new_data = session.get_data(data.name) assert new_data is not data # DATA-NOTE: Do we need an equality operator for data classes? These tests are very partial # Note that when they are created with load_arrays they seem to lose the name, which becomes the ID numpy.testing.assert_array_equal(new_data.get_indep(), data.get_indep()) numpy.testing.assert_array_equal(new_data.get_dep(), data.get_dep())