-
Notifications
You must be signed in to change notification settings - Fork 262
BUG: Use manager to set title #958
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #958 +/- ##
=======================================
Coverage 91.87% 91.87%
=======================================
Files 98 98
Lines 12451 12451
Branches 2193 2193
=======================================
Hits 11439 11439
Misses 678 678
Partials 334 334
Continue to review full report at Codecov.
|
nibabel/viewers.py
Outdated
@@ -118,8 +118,8 @@ def __init__(self, data, affine=None, axes=None, title=None): | |||
if self.n_volumes <= 1: | |||
fig.delaxes(self._axes[3]) | |||
self._axes.pop(-1) | |||
if self._title is not None: | |||
fig.canvas.set_window_title(str(title)) | |||
if self._title is not None and fig.canvas.manager is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a case where fig.canvas.manager
can be None
?
I've installed the minimum matplotlib (1.5.3) in a dev environment, and matplotlib.pyplot.gcf().canvas.manager
resolved fine. If this was being conservative to support older versions, then we can probably drop it. If there are configurations where it can actually be None
, then we should keep it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you instantiate the figure instance yourself (e.g., to embed in a Qt application of your own) instead of going through pyplot it's probably None. I haven't checked but there is probably some condition like this that causes it to be None.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verified that indeed fig.canvas.manager is None
if you embed on your own. But then I noticed that this code is in a block where we directly create fig
using pyplot
, so indeed we should be good to remove the conditional (I hope/presume)!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Deal with mpl deprecation: