There will be a short amount of downtime, for git.ligo.org, docs.ligo.org, and chat.ligo.org, starting around approximately 10am CDT on Tuesday 18th June 2019. This is to enable access controls for GitLab Pages. More information can be found here.

Commit 7799b43c authored by Jameson Graef Rollins's avatar Jameson Graef Rollins

CLI support systems with no display

matplotlib.pyplot throws a RuntimeError when no display is present.  One
way around that is to set the backend to AGG.  But we don't want AGG when
we do have a display.  So we only want to set it opportunistically.  But
it also has to be set before anything else is imported.  Kind of convoluted.

So we really just import pyplot as opportunistically as possible, and then
rely on setting AGG backend when we're sure we don't need it in main().
parent 0f4c8396
......@@ -3,7 +3,6 @@ import os
import signal
import argparse
import numpy as np
from matplotlib import pyplot as plt
from IPython.terminal.embed import InteractiveShellEmbed
import logging
......@@ -136,6 +135,18 @@ 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
......
from numpy import sqrt
import matplotlib.pyplot as plt
import logging
PRIORITY_MAP = {
'Quantum Vacuum': 0,
......@@ -80,6 +77,7 @@ def plot_noise(
f = noises['Freq']
if ax is None:
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(1, 1, 1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment