示例#1
0
def test_source_component_arbitrary_grid_int():
    from sherpa.astro.ui.utils import Session
    from sherpa.models import Const1D
    from sherpa.data import Data1DInt

    ui = Session()

    x = numpy.array([1, 2, 3]), numpy.array([2, 3, 4])
    y = [1.5, 2.5, 3.5]
    re_x = numpy.array([10, 20, 30]), numpy.array([20, 30, 40])

    ui.load_arrays(1, x[0], x[1], y, Data1DInt)
    model = Const1D('c')
    model.c0 = 10

    regrid_model = model.regrid(*re_x)

    with pytest.warns(UserWarning):
        ui.plot_source_component(regrid_model)

    x_points = (x[0] + x[1])/2
    re_x_points = (re_x[0] + re_x[1])/2
    points = numpy.concatenate((x_points, re_x_points))

    numpy.testing.assert_array_equal(ui._compsrcplot.x, points)
    numpy.testing.assert_array_equal(ui._compsrcplot.y, [10, 10, 10, 100, 100, 100])
示例#2
0
def test_source_component_arbitrary_grid_int():
    from sherpa.astro.ui.utils import Session
    from sherpa.models import Const1D
    from sherpa.data import Data1DInt

    ui = Session()

    x = numpy.array([1, 2, 3]), numpy.array([2, 3, 4])
    y = [1.5, 2.5, 3.5]
    re_x = numpy.array([10, 20, 30]), numpy.array([20, 30, 40])

    ui.load_arrays(1, x[0], x[1], y, Data1DInt)
    model = Const1D('c')
    model.c0 = 10

    regrid_model = model.regrid(*re_x)

    with pytest.warns(UserWarning):
        ui.plot_source_component(regrid_model)

    x_points = (x[0] + x[1]) / 2
    re_x_points = (re_x[0] + re_x[1]) / 2
    points = numpy.concatenate((x_points, re_x_points))

    numpy.testing.assert_array_equal(ui._compsrcplot.x, points)
    numpy.testing.assert_array_equal(ui._compsrcplot.y,
                                     [10, 10, 10, 100, 100, 100])
示例#3
0
def test_source_component_arbitrary_grid_int():
    ui = Session()

    x = numpy.array([1, 2, 3]), numpy.array([2, 3, 4])
    y = [1.5, 2.5, 3.5]
    re_x = numpy.array([10, 20, 30]), numpy.array([20, 30, 40])

    ui.load_arrays(1, x[0], x[1], y, Data1DInt)
    model = Const1D('c')
    model.c0 = 10

    regrid_model = model.regrid(*re_x)
    ui.plot_source_component(regrid_model)

    x_points = (x[0] + x[1]) / 2.0
    numpy.testing.assert_array_equal(ui._compsrcplot.x, x_points)
    numpy.testing.assert_array_equal(ui._compsrcplot.y, [0., 0., 0.])
示例#4
0
def test_source_component_arbitrary_grid():
    ui = Session()

    x = [1, 2, 3]
    y = [1, 2, 3]
    re_x = [10, 20, 30]

    ui.load_arrays(1, x, y)
    model = Const1D('c')
    model.c0 = 10

    regrid_model = model.regrid(re_x)

    with pytest.warns(UserWarning):
        ui.plot_source_component(regrid_model)

    numpy.testing.assert_array_equal(ui._compsrcplot.x, x + re_x)
    numpy.testing.assert_array_equal(ui._compsrcplot.y, [
        10,
    ] * 6)
示例#5
0
def test_source_component_arbitrary_grid():
    from sherpa.astro.ui.utils import  Session
    from sherpa.models import Const1D

    ui = Session()

    x = [1, 2, 3]
    y = [1, 2, 3]
    re_x = [10, 20, 30]

    ui.load_arrays(1, x, y)
    model = Const1D('c')
    model.c0 = 10

    regrid_model = model.regrid(re_x)

    with pytest.warns(UserWarning):
        ui.plot_source_component(regrid_model)

    numpy.testing.assert_array_equal(ui._compsrcplot.x, x + re_x)
    numpy.testing.assert_array_equal(ui._compsrcplot.y, [10, ]*6)