Closed
Description
Bug report
Getting a new exception in canary test on 3.3rc0.
Failure on travis
https://travis-ci.com/github/bashtage/statsmodels/jobs/353095057
Backend is tkAgg. This used to produce a warning.
error is produced calling
fig = plt.Figure()
# Some plotting
fig.tight_layout()
Code for reproduction
import matplotlib.pyplot as plt
from statsmodels.regression.rolling import RollingWLS
from statsmodels.regression.tests.test_rolling import gen_data
import pandas as pd
y, x, w = gen_data(250, 3, True, pandas=True)
fmla = 'y ~ 1 + x0 + x1 + x2'
data = pd.concat([y, x], axis=1)
mod = RollingWLS.from_formula(fmla, window=100, data=data, weights=w)
res = mod.fit()
fig = plt.Figure()
out = res.plot_recursive_coefficient(fig=fig)
Actual outcome
statsmodels/regression/rolling.py:732: in plot_recursive_coefficient
fig.tight_layout()
venv/lib/python3.8/site-packages/matplotlib/cbook/deprecation.py:410: in wrapper
return func(*inner_args, **inner_kwargs)
venv/lib/python3.8/site-packages/matplotlib/figure.py:2606: in tight_layout
renderer = get_renderer(self)
venv/lib/python3.8/site-packages/matplotlib/tight_layout.py:176: in get_renderer
return backend_bases._get_renderer(fig)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
figure = <Figure size 640x480 with 4 Axes>, print_method = None
def _get_renderer(figure, print_method=None):
"""
Get the renderer that would be used to save a `~.Figure`, and cache it on
the figure.
If you need a renderer without any active draw methods use
renderer._draw_disabled to temporary patch them out at your call site.
"""
# This is implemented by triggering a draw, then immediately jumping out of
# Figure.draw() by raising an exception.
class Done(Exception):
pass
def _draw(renderer): raise Done(renderer)
with cbook._setattr_cm(figure, draw=_draw):
if print_method is None:
fmt = figure.canvas.get_default_filetype()
> print_method = getattr(figure.canvas, f"print_{fmt}")
E AttributeError: 'FigureCanvasBase' object has no attribute 'print_png'
venv/lib/python3.8/site-packages/matplotlib/backend_bases.py:1550: AttributeError
Expected outcome
No error. Used to produce
c:\git\statsmodels\statsmodels\regression\rolling.py:732: UserWarning: tight_layout: falling back to Agg renderer
fig.tight_layout()
Works on all released from 2 to 3.2.
Matplotlib version
matplotlib: 3.3.0rc1+45.g7b9de2388 (/home/travis/build/bashtage/statsmodels/venv/lib/python3.8/site-packages/matplotlib)
backend: TkAgg
All installed versions:
INSTALLED VERSIONS
------------------
Python: 3.8.1.final.0
OS: Linux 5.0.0-1031-gcp #32-Ubuntu SMP Tue Feb 11 03:55:48 UTC 2020 x86_64
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
statsmodels
===========
Installed: v0.11.0+438.gc4e3dbdd4 (/home/travis/build/bashtage/statsmodels/statsmodels)
Required Dependencies
=====================
cython: 3.0a5 (/home/travis/build/bashtage/statsmodels/venv/lib/python3.8/site-packages/Cython)
numpy: 1.20.0.dev0+be8ab91 (/home/travis/build/bashtage/statsmodels/venv/lib/python3.8/site-packages/numpy)
scipy: 1.6.0.dev0+655ce1b (/home/travis/build/bashtage/statsmodels/venv/lib/python3.8/site-packages/scipy)
pandas: 1.1.0.dev0+1901.gaaa9cd03f (/home/travis/build/bashtage/statsmodels/venv/lib/python3.8/site-packages/pandas)
dateutil: 2.8.1 (/home/travis/build/bashtage/statsmodels/venv/lib/python3.8/site-packages/dateutil)
patsy: 0.5.1 (/home/travis/build/bashtage/statsmodels/venv/lib/python3.8/site-packages/patsy)
Optional Dependencies
=====================
matplotlib: 3.3.0rc1+45.g7b9de2388 (/home/travis/build/bashtage/statsmodels/venv/lib/python3.8/site-packages/matplotlib)
backend: TkAgg
cvxopt: 1.2.5 (/home/travis/build/bashtage/statsmodels/venv/lib/python3.8/site-packages/cvxopt)
joblib: 0.15.1 (/home/travis/build/bashtage/statsmodels/venv/lib/python3.8/site-packages/joblib)
Developer Tools
================
IPython: Not installed
jinja2: Not installed
sphinx: Not installed
pygments: Not installed
pytest: 5.4.3 (/home/travis/build/bashtage/statsmodels/venv/lib/python3.8/site-packages/pytest)
virtualenv: Not installed
Installed from nightlies on rackspace.