示例#1
0
    def test_source_methods_with_full_model(self):
        from sherpa.utils.err import IdentifierErr

        ui.load_data('full', self.ascii)
        ui.set_full_model('full', 'powlaw1d.p1')

        # Test Case 1
        try:
            ui.get_source('full')
        except IdentifierErr as e:
            self.assertRegex(
                str(e),
                "Convolved model\n.*\n is set for dataset full. You should use get_model instead.",
                str(e))
        try:
            ui.plot_source('full')
        except IdentifierErr as e:
            self.assertRegex(
                str(e),
                "Convolved model\n.*\n is set for dataset full. You should use plot_model instead.",
                str(e))

        # Test Case 2
        ui.set_source('full', 'powlaw1d.p2')
        ui.get_source('full')

        # Test Case 3
        ui.load_data('not_full', self.ascii)
        try:
            ui.get_source('not_full')
        except IdentifierErr as e:
            self.assertEqual(
                'source not_full has not been set, consider using set_source() or set_model()',
                str(e))
示例#2
0
def test_ui_source_methods_with_full_model(clean_ui, setup_ui_full):

    ui.load_data('full', setup_ui_full.ascii)
    ui.set_full_model('full', 'powlaw1d.p1')

    # Test Case 1
    with pytest.raises(IdentifierErr) as exc:
        ui.get_source('full')

    emsg = "Convolved model\n'powlaw1d.p1'\n is set for dataset full. You should use get_model instead."
    assert str(exc.value) == emsg

    with pytest.raises(IdentifierErr) as exc:
        ui.plot_source('full')

    emsg = "Convolved model\n'powlaw1d.p1'\n is set for dataset full. You should use plot_model instead."
    assert str(exc.value) == emsg

    with pytest.raises(IdentifierErr) as exc:
        ui.get_source_plot('full')

    emsg = "Convolved model\n'powlaw1d.p1'\n is set for dataset full. You should use get_model_plot instead."
    assert str(exc.value) == emsg

    # Test Case 2
    ui.set_source('full', 'powlaw1d.p2')
    ui.get_source('full')

    # Test Case 3
    ui.load_data('not_full', setup_ui_full.ascii)
    with pytest.raises(IdentifierErr) as exc:
        ui.get_source('not_full')

    emsg = 'source not_full has not been set, consider using set_source() or set_model()'
    assert emsg == str(exc.value)
示例#3
0
    def test_source_methods_with_full_model(self):
        from sherpa.utils.err import IdentifierErr

        ui.load_data('full', self.ascii)
        ui.set_full_model('full', 'powlaw1d.p1')

        # Test Case 1
        try:
            ui.get_source('full')
        except IdentifierErr as e:
            self.assertRegexpMatches(str(e), "Convolved model\n.*\n is set for dataset full. You should use get_model instead.", str(e))
        try:
            ui.plot_source('full')
        except IdentifierErr as e:
            self.assertEquals("Convolved model\n'p1'\n is set for dataset full. You should use plot_model instead.", str(e))

        # Test Case 2
        ui.set_source('full', 'powlaw1d.p2')
        ui.get_source('full')

        # Test Case 3
        ui.load_data('not_full', self.ascii)
        try:
            ui.get_source('not_full')
        except IdentifierErr as e:
            self.assertEquals('source not_full has not been set, consider using set_source() or set_model()', str(e))