8000 More style fixes. by anntzer · Pull Request #10615 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

More style fixes. #10615

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
Feb 27, 2018
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 load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lib/matplotlib/offsetbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,9 @@ def get_extent_offsets(self, renderer):

yoffsets = yoffsets - ydescent

return width + 2 * pad, height + 2 * pad, \
xdescent + pad, ydescent + pad, \
list(zip(xoffsets, yoffsets))
return (width + 2 * pad, height + 2 * pad,
xdescent + pad, ydescent + pad,
list(zip(xoffsets, yoffsets)))


class HPacker(PackerBase):
Expand Down Expand Up @@ -479,9 +479,9 @@ def get_extent_offsets(self, renderer):
xdescent = whd_list[0][2]
xoffsets = xoffsets - xdescent

return width + 2 * pad, height + 2 * pad, \
xdescent + pad, ydescent + pad, \
list(zip(xoffsets, yoffsets))
return (width + 2 * pad, height + 2 * pad,
xdescent + pad, ydescent + pad,
list(zip(xoffsets, yoffsets)))


class PaddedBox(OffsetBox):
Expand Down
9 changes: 4 additions & 5 deletions lib/matplotlib/textpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,7 @@ def get_text_path(self, prop, s, ismath=False, usetex=False):
def get_glyphs_with_font(self, font, s, glyph_map=None,
return_new_glyphs_only=False):
"""
convert the string *s* to vertices and codes using the
provided ttf font.
Convert string *s* to vertices and codes using the provided ttf font.
"""

# Mostly copied from backend_svg.py.
Expand Down Expand Up @@ -201,13 +200,13 @@ def get_glyphs_with_font(self, font, s, glyph_map=None,
kern = 0

glyph = font.load_char(ccode, flags=LOAD_NO_HINTING)
horiz_advance = (glyph.linearHoriAdvance / 65536.0)
horiz_advance = glyph.linearHoriAdvance / 65536

char_id = self._get_char_id(font, ccode)
if char_id not in glyph_map:
glyph_map_new[char_id] = self.glyph_to_path(font)

currx += (kern / 64.0)
currx += kern / 64

xpositions.append(currx)
glyph_ids.append(char_id)
Expand All @@ -222,7 +221,7 @@ def get_glyphs_with_font(self, font, s, glyph_map=None,
rects = []

return (list(zip(glyph_ids, xpositions, ypositions, sizes)),
glyph_map_new, rects)
glyph_map_new, rects)

def get_glyphs_mathtext(self, prop, s, glyph_map=None,
return_new_glyphs_only=False):
Expand Down
28 changes: 7 additions & 21 deletions lib/mpl_toolkits/axisartist/clip_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,8 @@ def clip(xlines, ylines, x0, clip="right", xdir=True, ydir=True):

_pos_angles = []

if xdir:
xsign = 1
else:
xsign = -1

if ydir:
ysign = 1
else:
ysign = -1

xsign = 1 if xdir else -1
ysign = 1 if ydir else -1

for x, y in zip(xlines, ylines):

Expand All @@ -46,7 +38,6 @@ def clip(xlines, ylines, x0, clip="right", xdir=True, ydir=True):
b = (x > x0).astype("i")
db = b[1:] - b[:-1]


if b[0]:
ns = 0
else:
Expand All @@ -56,7 +47,7 @@ def clip(xlines, ylines, x0, clip="right", xdir=True, ydir=True):
c = db[i]
if c == -1:
dx = (x0 - x[i])
dy = (y[i+1] - y[i]) * (dx/ (x[i+1] - x[i]))
dy = (y[i+1] - y[i]) * (dx / (x[i+1] - x[i]))
y0 = y[i] + dy
clipped_xlines.append(np.concatenate([segx, x[ns:i+1], [x0]]))
clipped_ylines.append(np.concatenate([segy, y[ns:i+1], [y0]]))
Expand Down Expand Up @@ -88,9 +79,6 @@ def clip(xlines, ylines, x0, clip="right", xdir=True, ydir=True):
clipped_xlines.append(np.concatenate([segx, x[ns:]]))
clipped_ylines.append(np.concatenate([segy, y[ns:]]))

#clipped_pos_angles.append(_pos_angles)


return clipped_xlines, clipped_ylines, _pos_angles


Expand Down Expand Up @@ -121,15 +109,13 @@ def clip_line_to_rect(xline, yline, bbox):
# ly3, lx3, c_top_ = clip(ly2, lx2, y1, clip="right")
# ly4, lx4, c_bottom_ = clip(ly3, lx3, y0, clip="left")

#c_left = [((x, y), (a+90)%180-180) for (x, y, a) in c_left_ \
# if bbox.containsy(y)]
c_left = [((x, y), (a+90)%180-90) for (x, y, a) in c_left_
c_left = [((x, y), (a + 90) % 180 - 90) for x, y, a in c_left_
if bbox.containsy(y)]
c_bottom = [((x, y), (90 - a)%180) for (y, x, a) in c_bottom_
c_bottom = [((x, y), (90 - a) % 180) for y, x, a in c_bottom_
if bbox.containsx(x)]
c_right = [((x, y), (a+90)%180+90) for (x, y, a) in c_right_
c_right = [((x, y), (a + 90) % 180 + 90) for x, y, a in c_right_
if bbox.containsy(y)]
c_top = [((x, y), (90 - a)%180+180) for (y, x, a) in c_top_
c_top = [((x, y), (90 - a) % 180 + 180) for y, x, a in c_top_
if bbox.containsx(x)]

return list(zip(lx4, ly4)), [c_left, c_bottom, c_right, c_top]
16 changes: 10 additions & 6 deletions lib/mpl_toolkits/mplot3d/axes3d.py
D7A7
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import six
from six.moves import map, zip, reduce

from collections import defaultdict
import math
import warnings
from collections import defaultdict

import numpy as np

Expand Down Expand Up @@ -210,17 +210,21 @@ def _init_axis(self):
ax.init3d()

def get_children(self):
return [self.zaxis, ] + super().get_children()
return [self.zaxis] + super().get_children()

def _get_axis_list(self):
return super()._get_axis_list() + (self.zaxis, )

def unit_cube(self, vals=None):
minx, maxx, miny, maxy, minz, maxz = vals or self.get_w_lims()
xs, ys, zs = ([minx, maxx, maxx, minx, minx, maxx, maxx, minx],
[miny, miny, maxy, maxy, miny, miny, maxy, maxy],
[minz, minz, minz, minz, maxz, maxz, maxz, maxz])
return list(zip(xs, ys, zs))
return [(minx, miny, minz),
(maxx, miny, minz),
(maxx, maxy, minz),
(minx, maxy, minz),
(minx, miny, maxz),
(maxx, miny, maxz),
(maxx, maxy, maxz),
(minx, maxy, maxz)]

def tunit_cube(self, vals=None, M=None):
if M is None:
Expand Down
35 changes: 17 additions & 18 deletions lib/mpl_toolkits/mplot3d/axis3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def draw(self, renderer):
ax_scale = self.axes.bbox.size / self.figure.bbox.size
ax_inches = np.multiply(ax_scale, self.figure.get_size_inches())
ax_points_estimate = sum(72. * ax_inches)
deltas_per_point = 48. / ax_points_estimate
deltas_per_point = 48 / ax_points_estimate
default_offset = 21.
labeldeltas = (
(self.labelpad + default_offset) * deltas_per_point * deltas)
Expand All @@ -305,24 +305,23 @@ def draw(self, renderer):
self.label.set_ha(info['label']['ha'])
self.label.draw(renderer)


# Draw Offset text

# Which of the two edge points do we want to
# use for locating the offset text?
if juggled[2] == 2 :
if juggled[2] == 2:
outeredgep = edgep1
outerindex = 0
else :
else:
outeredgep = edgep2
outerindex = 1

pos = copy.copy(outeredgep)
pos = move_from_center(pos, centers, labeldeltas, axmask)
olx, oly, olz = proj3d.proj_transform(
pos[0], pos[1], pos[2], renderer.M)
self.offsetText.set_text( self.major.formatter.get_offset() )
self.offsetText.set_position( (olx, oly) )
self.offsetText.set_text(self.major.formatter.get_offset())
self.offsetText.set_position((olx, oly))
angle = art3d.norm_text_angle(math.degrees(math.atan2(dy, dx)))
self.offsetText.set_rotation(angle)
# Must set rotation mode to "anchor" so that
Expand All @@ -344,29 +343,29 @@ def draw(self, renderer):
# Three-letters (e.g., TFT, FTT) are short-hand for the array of bools
# from the variable 'highs'.
# ---------------------------------------------------------------------
if centpt[info['tickdir']] > peparray[info['tickdir'], outerindex] :
if centpt[info['tickdir']] > peparray[info['tickdir'], outerindex]:
# if FT and if highs has an even number of Trues
if (centpt[index] <= peparray[index, outerindex]
and ((len(highs.nonzero()[0]) % 2) == 0)) :
and len(highs.nonzero()[0]) % 2 == 0):
# Usually, this means align right, except for the FTT case,
# in which offset for axis 1 and 2 are aligned left.
if highs.tolist() == [False, True, True] and index in (1, 2) :
if highs.tolist() == [False, True, True] and index in (1, 2):
align = 'left'
else :
else:
align = 'right'
else :
else:
# The FF case
align = 'left'
else :
else:
# if TF and if highs has an even number of Trues
if (centpt[index] > peparray[index, outerindex]
and ((len(highs.nonzero()[0]) % 2) == 0)) :
and len(highs.nonzero()[0]) % 2 == 0):
# Usually mean align left, except if it is axis 2
if index == 2 :
if index == 2:
align = 'right'
else :
else:
align = 'left'
else :
else:
# The TT case
align = 'right'

Expand All @@ -385,7 +384,7 @@ def draw(self, renderer):

# Grid points at end of the other plane
xyz2 = copy.deepcopy(xyz0)
newindex = (index + 2) % 3
newindex = (index + 2) % 3
newval = get_flip_min_max(xyz2[0], newindex, mins, maxs)
for i in range(len(majorLocs)):
xyz2[i][newindex] = newval
Expand Down Expand Up @@ -461,7 +460,7 @@ def set_view_interval(self, vmin, vmax, ignore=False):

# TODO: Get this to work properly when mplot3d supports
# the transforms framework.
def get_tightbbox(self, renderer) :
def get_tightbbox(self, renderer):
# Currently returns None so that Axis.get_tightbbox
# doesn't return junk info.
return None
Expand Down
0