Ejemplo n.º 1
0
def test_plot_save_saves_plot(mock_save, dummy_data):
    sph_obj, _, m, _, el, ss = dummy_data
    cl = StaticGeodesicPlotter(m)
    cl.plot(sph_obj, el, ss)
    name = "test_plot.png"
    cl.save(name)
    mock_save.assert_called_with(name)
Ejemplo n.º 2
0
def test_plot_calls_draw_attractor_Manualscale(dummy_data):
    sph_obj, _, m, _, el, ss = dummy_data
    cl = StaticGeodesicPlotter(m, attractor_radius_scale=1500)
    cl.plot(sph_obj, el, ss)
    assert cl._attractor_present
    assert cl.attractor_radius_scale == 1500
    assert cl.get_curr_plot_radius != -1
Ejemplo n.º 3
0
def test_plot_calls_plt_show(mock_show, dummy_data):
    sph_obj, _, m, _, el, ss = dummy_data
    cl = StaticGeodesicPlotter(m)
    cl.plot(sph_obj, el, ss)
    cl.show()
    mock_show.assert_called_with()
    assert cl._attractor_present
Ejemplo n.º 4
0
def test_plot_save_saves_plot(mock_save, dummy_data):
    geodesic = dummy_data
    cl = StaticGeodesicPlotter()
    cl.plot(geodesic)
    name = "test_plot.png"
    cl.save(name)
    mock_save.assert_called_with(name)
Ejemplo n.º 5
0
def test_static_geod_plotter_has_axes(dummy_geod):
    geod = dummy_geod

    sgpl = StaticGeodesicPlotter()
    sgpl.plot(geod)

    assert isinstance(sgpl.ax, Axes)
Ejemplo n.º 6
0
def test_plot_calls_plt_show(mock_show, dummy_data):
    geodesic = dummy_data
    cl = StaticGeodesicPlotter()
    cl.plot(geodesic)
    cl.show()
    mock_show.assert_called_with()
    assert cl.attractor_present
Ejemplo n.º 7
0
def test_plot_calls_plt_geod_show_view_init(mock_show, dummy_geod):
    geod = dummy_geod

    sgpl = StaticGeodesicPlotter()
    sgpl.plot(geod)
    sgpl.show(azim=-60, elev=30)

    mock_show.assert_called_with()
Ejemplo n.º 8
0
def test_plot_calls_plt_geod_show(mock_show, dummy_geod):
    geod = dummy_geod

    sgpl = StaticGeodesicPlotter()
    sgpl.plot(geod)
    sgpl.show()

    mock_show.assert_called_with()
Ejemplo n.º 9
0
def test_plot_in_3d(mock_show, dummy_data):
    geodesic = dummy_data
    cl = StaticGeodesicPlotter(use_3d=True)
    cl.plot(geodesic)
    cl.show()
    mock_show.assert_called_with()
    assert cl.attractor_present
    assert cl.ax.name == "3d"
Ejemplo n.º 10
0
def test_static_geod_plotter_show_clear(mock_show, dummy_geod):
    geod = dummy_geod

    sgpl = StaticGeodesicPlotter(draw_ergosphere=False)
    sgpl.plot(geod)
    sgpl.show()

    mock_show.assert_called_with()
    sgpl.clear()
    assert sgpl.fig.get_axes() == []
Ejemplo n.º 11
0
def test_plot_geod_save_saves_plot(mock_save, dummy_geod):
    geod = dummy_geod

    sgpl = StaticGeodesicPlotter()
    sgpl.plot(geod)
    name = "test_plot.png"
    sgpl.save(name)

    mock_save.assert_called_with(name)
    assert sgpl.ax.name == "3d"
Ejemplo n.º 12
0
def test_plot_calls_plot_attractor(mock_plot_attractor):
    r = [306 * u.m, np.pi / 2 * u.rad, np.pi / 2 * u.rad]
    v = [0 * u.m / u.s, 0 * u.rad / u.s, 951.0 * u.rad / u.s]
    m = 4e24 * u.kg
    el = 0.002
    ss = 0.5e-6
    cl = StaticGeodesicPlotter(m)
    cl.plot(r, v, el, ss)
    mock_plot_attractor.assert_called_with()
    assert cl._attractor_present
Ejemplo n.º 13
0
def test_plot_save_saves_plot(mock_save):
    r = [306 * u.m, np.pi / 2 * u.rad, np.pi / 2 * u.rad]
    v = [0 * u.m / u.s, 0 * u.rad / u.s, 951.0 * u.rad / u.s]
    m = 4e24 * u.kg
    el = 0.002
    ss = 0.5e-6
    cl = StaticGeodesicPlotter(m)
    cl.plot(r, v, el, ss)
    name = "test_plot.png"
    cl.save(name)
    mock_save.assert_called_with(name)
Ejemplo n.º 14
0
def test_set_scaling(dummy_data):
    geodesic = dummy_data
    cl = StaticGeodesicPlotter(use_3d=True)
    cl.plot(geodesic)
    cl._set_scaling(10, 1e-6, 10, 1e-5)
    cl._set_scaling(1e-6, 1e-6, 1e-6, 1e-5)
    zmin, zmax = cl.ax.get_zlim()
    ymin, ymax = cl.ax.get_ylim()
    xmin, xmax = cl.ax.get_xlim()
    assert xmin != -1e-5 and xmax != 1e-5
    assert ymin == -1e-5 and ymax == 1e-5
    assert zmin == -1e-5 and zmax == 1e-5
Ejemplo n.º 15
0
def Plot(Attractor, sph_obj, simLength=0.002):
    '''Plots with given attractor and bodies. Note: increasing simLength gives longer simulation but takes longer to load'''
    plt.close()
    obj = StaticGeodesicPlotter()
    #Adding the body to the attractor
    Object = Body(differential=sph_obj, parent=Attractor)
    #Define geometry i.e. Schwarzschild
    geodesic = Geodesic(body=Object,
                        time=startTime * u.s,
                        end_lambda=simLength,
                        step_size=sSize)
    #Plotting the trajectory
    obj.plot(geodesic)
    plt.title("Plot of Orbit")
    #Plot Visuals
    fig = plt.gcf()
    fig.canvas.set_window_title("Plot of Orbit")
    plt.show()
Ejemplo n.º 16
0
def test_plot_calls_draw_attractor_AutoScale(dummy_data):
    geodesic = dummy_data
    cl = StaticGeodesicPlotter()
    cl.plot(geodesic)
    assert cl.attractor_present
Ejemplo n.º 17
0
def test_plot_calls_draw_attractor_Manualscale(dummy_data):
    geodesic = dummy_data
    cl = StaticGeodesicPlotter(attractor_radius_scale=1500)
    cl.plot(geodesic)
    assert cl.attractor_present
    assert cl.attractor_radius_scale == 1500
Ejemplo n.º 18
0
def test_plot_calls_draw_attractor_AutoScale(dummy_data):
    sph_obj, _, m, _, el, ss = dummy_data
    cl = StaticGeodesicPlotter(m)
    cl.plot(sph_obj, el, ss)
    assert cl._attractor_present
    assert cl.get_curr_plot_radius != -1