Skip to content

Commit a4989a9

Browse files
committed
Fix imports for filewriter to work properly with sphinx
1 parent 46ab688 commit a4989a9

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

eqtools/filewriter.py

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,20 @@
2020
import scipy.interpolate
2121
import warnings
2222
import time
23-
import core
24-
import matplotlib.pyplot as plt
23+
24+
from . import core
25+
26+
try:
27+
import matplotlib.pyplot as plt
28+
_has_plt = False
29+
except Exception:
30+
warnings.warn(
31+
"Matplotlib.pyplot module could not be loaded -- classes that use "
32+
"pyplot will not work.",
33+
ModuleWarning
34+
)
35+
_has_plt = False
36+
2537
try:
2638
from . import trispline
2739
_has_trispline = True
@@ -259,6 +271,9 @@ def _findLCFS(rgrid, zgrid, psiRZ, rcent, zcent, psiLCFS, nbbbs=100):
259271
""" internal function for finding the last closed flux surface
260272
based off of a Equilibrium instance"""
261273

274+
if not _has_plt:
275+
raise RuntimeError('Need matplotlib to run _findLCFS!')
276+
262277
ang = numpy.linspace(-numpy.pi, numpy.pi, nbbbs)
263278

264279
plt.ioff()

0 commit comments

Comments
 (0)