Skip to content

Commit

Permalink
Prevent import errors if plotting will not be used
Browse files Browse the repository at this point in the history
Fix poliastro#629.
For a better error message when ipywidgets is missing,
see plotly/plotly.py#1111
  • Loading branch information
astrojuanlu authored and Sedictious committed Jun 25, 2019
1 parent a509475 commit 5062d73
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/poliastro/twobody/orbit.py
Expand Up @@ -18,8 +18,6 @@
from poliastro.core.angles import nu_to_M as nu_to_M_fast
from poliastro.core.elements import rv2coe
from poliastro.frames import Planes, get_frame
from poliastro.plotting.core import OrbitPlotter2D, OrbitPlotter3D
from poliastro.plotting.static import StaticOrbitPlotter
from poliastro.twobody.angles import E_to_nu, M_to_nu, nu_to_M
from poliastro.twobody.propagation import mean_motion, propagate
from poliastro.util import (
Expand Down Expand Up @@ -1168,8 +1166,14 @@ def plot(self, label=None, use_3d=False, interactive=False):
"The static plotter does not support 3D, use `interactive=True`"
)
elif not interactive:
from poliastro.plotting.static import StaticOrbitPlotter

return StaticOrbitPlotter().plot(self, label=label)
elif use_3d:
from poliastro.plotting.core import OrbitPlotter3D

return OrbitPlotter3D().plot(self, label=label)
else:
from poliastro.plotting.core import OrbitPlotter2D

return OrbitPlotter2D().plot(self, label=label)

0 comments on commit 5062d73

Please sign in to comment.