From 82dee4a1573b0a8556e1bb2bfb41e1b2a0be4092 Mon Sep 17 00:00:00 2001 From: Jameson Graef Rollins <jrollins@finestructure.net> Date: Wed, 29 Aug 2018 00:00:30 -0700 Subject: [PATCH] don't import matplotlib at all if not plotting --- gwinc/__main__.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/gwinc/__main__.py b/gwinc/__main__.py index f23856ca..662c7926 100644 --- a/gwinc/__main__.py +++ b/gwinc/__main__.py @@ -111,6 +111,18 @@ def main(): ifo = precompIFO(ifo) print(ifo.to_txt(), end='') return + if args.plot: + if args.save: + # FIXME: this silliness seems to be the only way to have + # matplotlib usable on systems without a display. There must + # be a better way. 'AGG' is a backend that works without + # displays. but it has to be set before any other matplotlib + # stuff is imported. and we *don't* want it set if we do want + # to show an interactive plot. there doesn't seem a way to + # set this opportunistically. + import matplotlib + matplotlib.use('AGG') + from matplotlib import pyplot as plt if args.matlab: gwinc = gwinc_matlab.gwinc_matlab @@ -135,18 +147,6 @@ def main(): v = float(v) range_params[p] = v - if args.save: - # FIXME: this silliness seems to be the only way to have - # matplotlib usable on systems without a display. There must - # be a better way. 'AGG' is a backend that works without - # displays. but it has to be set before any other matplotlib - # stuff is imported. and we *don't* want it set if we do want - # to show an interactive plot. there doesn't seem a way to - # set this opportunistically. - import matplotlib - matplotlib.use('AGG') - from matplotlib import pyplot as plt - ########## # main calculations -- GitLab