8000 pep8ify a couple of variable names. by anntzer · Pull Request #14273 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

pep8ify a couple of variable names. #14273

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

Merged
merged 1 commit into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to 8000 load files.
Loading
Diff view
Diff view
83 changes: 39 additions & 44 deletions lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,23 +857,23 @@ def _print_ps(self, outfile, format, *args,
orientation = orientation.lower()
cbook._check_in_list(['landscape', 'portrait'],
orientation=orientation)
isLandscape = (orientation == 'landscape')
is_landscape = (orientation == 'landscape')

self.figure.set_dpi(72) # Override the dpi kwarg

if rcParams['text.usetex']:
self._print_figure_tex(outfile, format, dpi, facecolor, edgecolor,
orientation, isLandscape, papertype,
orientation, is_landscape, papertype,
**kwargs)
else:
self._print_figure(outfile, format, dpi, facecolor, edgecolor,
orientation, isLandscape, papertype,
orientation, is_landscape, papertype,
**kwargs)

@cbook._delete_parameter("3.2", "dryrun")
def _print_figure(
self, outfile, format, dpi=72, facecolor='w', edgecolor='w',
orientation='portrait', isLandscape=False, papertype=None,
orientation='portrait', is_landscape=False, papertype=None,
metadata=None, *,
dryrun=False, bbox_inches_restore=None, **kwargs):
"""
Expand All @@ -892,7 +892,7 @@ def _print_figure(
metadata must be a dictionary. Currently, only the value for
the key 'Creator' is used.
"""
isEPSF = format == 'eps'
is_eps = format == 'eps'
if isinstance(outfile, (str, os.PathLike)):
outfile = title = os.fspath(outfile)
title = title.encode("ascii", "replace").decode("ascii")
Expand All @@ -906,40 +906,40 @@ def _print_figure(
# find the appropriate papertype
width, height = self.figure.get_size_inches()
if papertype == 'auto':
if isLandscape:
if is_landscape:
papertype = _get_papertype(height, width)
else:
papertype = _get_papertype(width, height)

if isLandscape:
paperHeight, paperWidth = papersize[papertype]
if is_landscape:
paper_height, paper_width = papersize[papertype]
else:
paperWidth, paperHeight = papersize[papertype]
paper_width, paper_height = papersize[papertype]

if rcParams['ps.usedistiller'] and not papertype == 'auto':
# distillers will improperly clip eps files if the pagesize is
# too small
if width > paperWidth or height > paperHeight:
if isLandscape:
if width > paper_width or height > paper_height:
if is_landscape:
papertype = _get_papertype(height, width)
paperHeight, paperWidth = papersize[papertype]
paper_height, paper_width = papersize[papertype]
else:
papertype = _get_papertype(width, height)
paperWidth, paperHeight = papersize[papertype]
paper_width, paper_height = papersize[papertype]

# center the figure on the paper
xo = 72 * 0.5 * (paperWidth - width)
yo = 72 * 0.5 * (paperHeight - height)
xo = 72 * 0.5 * (paper_width - width)
yo = 72 * 0.5 * (paper_height - height)

l, b, w, h = self.figure.bbox.bounds
llx = xo
lly = yo
urx = llx + w
ury = lly + h
rotation = 0
if isLandscape:
if is_landscape:
llx, lly, urx, ury = lly, llx, ury, urx
xo, yo = 72 * paperHeight - yo, xo
xo, yo = 72 * paper_height - yo, xo
rotation = 90
bbox = (llx, lly, urx, ury)

Expand Down Expand Up @@ -981,7 +981,7 @@ def write(self, *args, **kwargs):

def print_figure_impl(fh):
# write the PostScript headers
if isEPSF:
if is_eps:
print("%!PS-Adobe-3.0 EPSF-3.0", file=fh)
else:
print("%!PS-Adobe-3.0\n"
Expand Down Expand Up @@ -1053,7 +1053,7 @@ def print_figure_impl(fh):
print("end", file=fh)
print("%%EndProlog", file=fh)

if not isEPSF:
if not is_eps:
print("%%Page: 1 1", file=fh)
print("mpldict begin", file=fh)

Expand All @@ -1072,7 +1072,7 @@ def print_figure_impl(fh):
# write the trailer
print("end", file=fh)
print("showpage", file=fh)
if not isEPSF:
if not is_eps:
print("%%EOF", file=fh)
fh.flush()

Expand All @@ -1084,9 +1084,9 @@ def print_figure_impl(fh):
with open(tmpfile, 'w', encoding='latin-1') as fh:
print_figure_impl(fh)
if rcParams['ps.usedistiller'] == 'ghostscript':
gs_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox)
gs_distill(tmpfile, is_eps, ptype=papertype, bbox=bbox)
elif rcParams['ps.usedistiller'] == 'xpdf':
xpdf_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox)
xpdf_distill(tmpfile, is_eps, ptype=papertype, bbox=bbox)
_move_path_to_path_or_stream(tmpfile, outfile)

else:
Expand All @@ -1109,7 +1109,7 @@ def print_figure_impl(fh):

def _print_figure_tex(
self, outfile, format, dpi, facecolor, edgecolor,
orientation, isLandscape, papertype, metadata=None, *,
orientation, is_landscape, papertype, metadata=None, *,
dryrun=False, bbox_inches_restore=None, **kwargs):
"""
If text.usetex is True in rc, a temporary pair of tex/eps files
Expand All @@ -1119,7 +1119,7 @@ def _print_figure_tex(
metadata must be a dictionary. Currently, only the value for
the key 'Creator' is used.
"""
isEPSF = format == 'eps'
is_eps = format == 'eps'
if is_writable_file_like(outfile):
title = None
else:
Expand Down Expand Up @@ -1227,54 +1227,49 @@ def write(self, *args, **kwargs):
print("showpage", file=fh)
fh.flush()

if isLandscape: # now we are ready to rotate
isLandscape = True
if is_landscape: # now we are ready to rotate
is_landscape = True
width, height = height, width
bbox = (lly, llx, ury, urx)

# set the paper size to the figure size if isEPSF. The
# set the paper size to the figure size if is_eps. The
# resulting ps file has the given size with correct bounding
# box so that there is no need to call 'pstoeps'
if isEPSF:
paperWidth, paperHeight = self.figure.get_size_inches()
if isLandscape:
paperWidth, paperHeight = paperHeight, paperWidth
if is_eps:
paper_width, paper_height = self.figure.get_size_inches()
if is_landscape:
paper_width, paper_height = paper_height, paper_width
else:
temp_papertype = _get_papertype(width, height)
if papertype == 'auto':
papertype = temp_papertype
paperWidth, paperHeight = papersize[temp_papertype]
paper_width, paper_height = papersize[temp_papertype]
else:
paperWidth, paperHeight = papersize[papertype]
if (width > paperWidth or height > paperHeight) and isEPSF:
paperWidth, paperHeight = papersize[temp_papertype]
_log.info('Your figure is too big to fit on %s paper. '
'%s paper will be used to prevent clipping.',
papertype, temp_papertype)
paper_width, paper_height = papersize[papertype]

texmanager = ps_renderer.get_texmanager()
font_preamble = texmanager.get_font_preamble()
custom_preamble = texmanager.get_custom_preamble()

psfrag_rotated = convert_psfrags(tmpfile, ps_renderer.psfrag,
font_preamble,
custom_preamble, paperWidth,
paperHeight,
custom_preamble, paper_width,
paper_height,
orientation)

if (rcParams['ps.usedistiller'] == 'ghostscript'
or rcParams['text.usetex']):
gs_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox,
gs_distill(tmpfile, is_eps, ptype=papertype, bbox=bbox,
rotated=psfrag_rotated)
elif rcParams['ps.usedistiller'] == 'xpdf':
xpdf_distill(tmpfile, isEPSF, ptype=papertype, bbox=bbox,
xpdf_distill(tmpfile, is_eps, ptype=papertype, bbox=bbox,
rotated=psfrag_rotated)

_move_path_to_path_or_stream(tmpfile, outfile)


def convert_psfrags(tmpfile, psfrags, font_preamble, custom_preamble,
paperWidth, paperHeight, orientation):
paper_width, paper_height, orientation):
"""
When we want to use the LaTeX backend with postscript, we write PSFrag tags
to a temporary postscript file, each one marking a position for LaTeX to
Expand Down Expand Up @@ -1319,7 +1314,7 @@ def convert_psfrags(tmpfile, psfrags, font_preamble, custom_preamble,
\end{figure}
\end{document}
""" % (font_preamble, unicode_preamble, custom_preamble,
paperWidth, paperHeight, paperWidth, paperHeight,
paper_width, paper_height, paper_width, paper_height,
'\n'.join(psfrags), angle, os.path.split(epsfile)[-1])

try:
Expand Down
8 changes: 4 additions & 4 deletions lib/matplotlib/mlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

import csv
import inspect
from numbers import Number

import numpy as np

Expand Down Expand Up @@ -1456,15 +1457,14 @@ def __init__(self, dataset, bw_method=None):
raise ValueError("`dataset` input should have multiple elements.")

self.dim, self.num_dp = np.array(self.dataset).shape
isString = isinstance(bw_method, str)

if bw_method is None:
pass
elif (isString and bw_method == 'scott'):
elif cbook._str_equal(bw_method, 'scott'):
self.covariance_factor = self.scotts_factor
elif (isString and bw_method == 'silverman'):
elif cbook._str_equal(bw_method, 'silverman'):
self.covariance_factor = self.silverman_factor
elif (np.isscalar(bw_method) and not isString):
elif isinstance(bw_method, Number):
self._bw_method = 'use constant'
self.covariance_factor = lambda: bw_method
elif callable(bw_method):
Expand Down
0