Skip to content

Commit 57c03b3

Browse files
author
Gerry Manoim
committed
Force non interactive if no display
1 parent e5d7a46 commit 57c03b3

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

alphalens/plotting.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,25 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16+
import os
1617
import numpy as np
1718
import pandas as pd
1819
from scipy import stats
1920
import statsmodels.api as sm
2021

22+
import matplotlib
23+
if os.environ.get('DISPLAY', '') == '':
24+
print('no display found. Using non-interactive Agg backend')
25+
matplotlib.use('Agg')
2126
import seaborn as sns
22-
import matplotlib.cm as cm
23-
import matplotlib.pyplot as plt
24-
from matplotlib.ticker import ScalarFormatter
27+
import matplotlib.cm as cm # noqa: E402
28+
import matplotlib.pyplot as plt # noqa: E402
29+
from matplotlib.ticker import ScalarFormatter # noqa: E402
2530

26-
from functools import wraps
31+
from functools import wraps # noqa: E402
2732

28-
from . import utils
29-
from . import performance as perf
33+
from . import utils # noqa: E402
34+
from . import performance as perf # noqa: E402
3035

3136
DECIMAL_TO_BPS = 10000
3237

alphalens/tears.py

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,19 @@
1212
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
15-
16-
17-
import matplotlib.gridspec as gridspec
18-
import matplotlib.pyplot as plt
19-
import pandas as pd
20-
import warnings
21-
22-
from . import plotting
23-
from . import performance as perf
24-
from . import utils
15+
import os
16+
import matplotlib
17+
if os.environ.get('DISPLAY', '') == '':
18+
print('no display found. Using non-interactive Agg backend')
19+
matplotlib.use('Agg')
20+
import matplotlib.gridspec as gridspec # noqa: E402
21+
import matplotlib.pyplot as plt # noqa: E402
22+
import pandas as pd # noqa: E402
23+
import warnings # noqa: E402
24+
25+
from . import plotting # noqa: E402
26+
from . import performance as perf # noqa: E402
27+
from . import utils # noqa: E402
2528

2629

2730
class GridFigure(object):

0 commit comments

Comments
 (0)