8000 flake8 linting · ipython/matplotlib-inline@07e742c · GitHub
[go: up one dir, main page]

Skip to content

Commit 07e742c

Browse files
committed
flake8 linting
1 parent 85aef44 commit 07e742c

File tree

3 files changed

+36
-26
lines changed

3 files changed

+36
-26
lines changed

matplotlib_inline/backend_inline.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
# Distributed under the terms of the BSD 3-Clause License.
55

66
import matplotlib
7-
from matplotlib.backends.backend_agg import (
7+
from matplotlib.backends.backend_agg import ( # noqa
88
new_figure_manager,
99
FigureCanvasAgg,
1010
new_figure_manager_given_figure,
11-
) # analysis: ignore
11+
)
1212
from matplotlib import colors
1313
from matplotlib._pylab_helpers import Gcf
1414

@@ -129,7 +129,7 @@ def flush_figures():
129129
try:
130130
# exclude any figures that were closed:
131131
active = set([fm.canvas.figure for fm in Gcf.get_all_fig_managers()])
132-
for fig in [ fig for fig in show._to_draw if fig in active ]:
132+
for fig in [fig for fig in show._to_draw if fig in active]:
133133
try:
134134
display(fig, metadata=_fetch_figure_metadata(fig))
135135
except Exception as e:
@@ -218,8 +218,10 @@ def configure_once(*args):
218218
ip.events.unregister('post_run_cell', configure_once)
219219
ip.events.register('post_run_cell', configure_once)
220220

221+
221222
_enable_matplotlib_integration()
222223

224+
223225
def _fetch_figure_metadata(fig):
224226
"""Get some metadata to help with displaying a figure."""
225227
# determine if a background is needed for legibility
@@ -235,12 +237,14 @@ def _fetch_figure_metadata(fig):
235237

236238
return None
237239

240+
238241
def _is_light(color):
239242
"""Determines if a color (or each of a sequence of colors) is light (as
240243
opposed to dark). Based on ITU BT.601 luminance formula (see
241244
https://stackoverflow.com/a/596241)."""
242245
rgbaArr = colors.to_rgba_array(color)
243-
return rgbaArr[:,:3].dot((.299, .587, .114)) > .5
246+
return rgbaArr[:, :3].dot((.299, .587, .114)) > .5
247+
244248

245249
def _is_transparent(color):
246250
"""Determine transparency from alpha."""

matplotlib_inline/config.py

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,49 +11,52 @@
1111
Dict, Instance, Set, Bool, TraitError, Unicode
1212
)
1313

14-
#-----------------------------------------------------------------------------
15-
# Configurable for inline backend options
16-
#-----------------------------------------------------------------------------
1714

15+
# Configurable for inline backend options
1816
def pil_available():
1917
"""Test if PIL/Pillow is available"""
2018
out = False
2119
try:
22-
from PIL import Image
20+
from PIL import Image # noqa
2321
out = True
24-
except:
22+
except ImportError:
2523
pass
2624
return out
2725

28-
# inherit from InlineBackendConfig for deprecation purposes
26+
27+
# Inherit from InlineBackendConfig for deprecation purposes
2928
class InlineBackendConfig(SingletonConfigurable):
3029
pass
3130

31+
3232
class InlineBackend(InlineBackendConfig):
3333
"""An object to store configuration of the inline backend."""
3434

3535
# The typical default figure size is too large for inline use,
3636
# so we shrink the figure size to 6x4, and tweak fonts to
3737
# make that fit.
38-
rc = Dict({'figure.figsize': (6.0,4.0),
39-
# play nicely with white background in the Qt and notebook frontend
40-
'figure.facecolor': (1,1,1,0),
41-
'figure.edgecolor': (1,1,1,0),
42-
# 12pt labels get cutoff on 6x4 logplots, so use 10pt.
43-
'font.size': 10,
44-
# 72 dpi matches SVG/qtconsole
45-
# this only affects PNG export, as SVG has no dpi setting
46-
'figure.dpi': 72,
47-
# 10pt still needs a little more room on the xlabel:
48-
'figure.subplot.bottom' : .125
38+
rc = Dict(
39+
{
40+
'figure.figsize': (6.0, 4.0),
41+
# play nicely with white background in the Qt and notebook frontend
42+
'figure.facecolor': (1, 1, 1, 0),
43+
'figure.edgecolor': (1, 1, 1, 0),
44+
# 12pt labels get cutoff on 6x4 logplots, so use 10pt.
45+
'font.size': 10,
46+
# 72 dpi matches SVG/qtconsole
47+
# this only affects PNG export, as SVG has no dpi setting
48+
'figure.dpi': 72,
49+
# 10pt still needs a little more room on the xlabel:
50+
'figure.subplot.bottom': .125
4951
},
5052
help="""Subset of matplotlib rcParams that should be different for the
5153
inline backend."""
5254
).tag(config=True)
5355

54-
figure_formats = Set({'png'},
55-
help="""A set of figure formats to enable: 'png',
56-
'retina', 'jpeg', 'svg', 'pdf'.""").tag(config=True)
56+
figure_formats = Set(
57+
{'png'},
58+
help="""A set of figure formats to enable: 'png',
59+
'retina', 'jpeg', 'svg', 'pdf'.""").tag(config=True)
5760

5861
def _update_figure_formatters(self):
5962
if self.shell is not None:
@@ -73,15 +76,17 @@ def _figure_format_changed(self, name, old, new):
7376
if new:
7477
self.figure_formats = {new}
7578

76-
print_figure_kwargs = Dict({'bbox_inches' : 'tight'},
79+
print_figure_kwargs = Dict(
80+
{'bbox_inches': 'tight'},
7781
help="""Extra kwargs to be passed to fig.canvas.print_figure.
7882
7983
Logical examples include: bbox_inches, quality (for jpeg figures), etc.
8084
"""
8185
).tag(config=True)
8286
_print_figure_kwargs_changed = _update_figure_formatters
8387

84-
close_figures = Bool(True,
88+
close_figures = Bool(
89+
True,
8590
help="""Close all figures at the end of each cell.
8691
8792
When True, ensures that each cell starts with no active figures, but it

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
python_requires='>=3.5',
1818
install_requires=[
1919
'matplotlib',
20+
'traitlets',
2021
'ipython'
2122
],
2223
extras_require={

0 commit comments

Comments
 (0)
0