Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_set_frame_plots_same_colors():
# TODO: Review
op = StaticOrbitPlotter()
op.plot_body_orbit(Jupiter, J2000)
colors1 = [orb[2] for orb in op.trajectories]
op.set_body_frame(Jupiter)
colors2 = [orb[2] for orb in op.trajectories]
assert colors1 == colors2
def test_plot_trajectory_sets_label():
expected_label = "67P"
op = StaticOrbitPlotter()
trajectory = churi.sample()
op.plot_body_orbit(Mars, J2000, label="Mars")
op.plot_trajectory(trajectory, label=expected_label)
legend = plt.gca().get_legend()
assert legend.get_texts()[1].get_text() == expected_label
def test_basic_trajectory_plotting():
fig, ax = plt.subplots()
plotter = StaticOrbitPlotter(ax=ax)
plotter.set_attractor(Earth)
plotter.set_orbit_frame(iss)
plotter.plot_trajectory(iss.sample())
return fig
def test_plot_ephem_no_epoch():
epoch = Time("2020-02-14 00:00:00")
ephem = Ephem.from_horizons(
"2020 CD3",
time_range(Time("2020-02-13 12:00:00"), end=Time("2020-02-14 12:00:00")),
attractor=Earth,
)
fig, ax = plt.subplots()
plotter = StaticOrbitPlotter(ax=ax)
plotter.set_attractor(Earth)
plotter.set_orbit_frame(Orbit.from_ephem(Earth, ephem, epoch))
plotter.plot_ephem(ephem, label="2020 CD3 Minimoon", color="k")
return fig
def test_color():
op = StaticOrbitPlotter()
ss = iss
c = "#FF0000"
op.plot(ss, label="ISS", color=c)
ax = plt.gca()
assert ax.get_legend().get_lines()[0].get_c() == c
for element in ax.get_lines():
assert element.get_c() == c
def test_redraw_makes_attractor_none():
# TODO: Review
op = StaticOrbitPlotter()
op._redraw()
assert op._attractor_radius is not None
def test_dark_mode_plots_dark_plot(dark, expected_color):
op = StaticOrbitPlotter(dark=dark)
assert op._ax.get_facecolor() == expected_color
def test_basic_orbit_and_trajectory_plotting():
fig, ax = plt.subplots()
plotter = StaticOrbitPlotter(ax=ax)
plotter.plot(iss)
plotter.plot_trajectory(molniya.sample(), label="Molniya")
return fig
def test_trail_plotting():
fig, ax = plt.subplots()
plotter = StaticOrbitPlotter(ax=ax)
plotter.plot(iss, trail=True)
return fig
def test_legend():
op = StaticOrbitPlotter()
ss = iss
op.plot(ss, label="ISS")
legend = plt.gca().get_legend()
ss.epoch.out_subfmt = "date_hm"
label = f"{ss.epoch.iso} (ISS)"
assert legend.get_texts()[0].get_text() == label