8000 Merge pull request #10615 from anntzer/morestyle · matplotlib/matplotlib@6874c42 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6874c42

Browse files
authored
Merge pull request #10615 from anntzer/morestyle
More style fixes.
2 parents 357dad0 + aa9c05f commit 6874c42

File tree

5 files changed

+44
-56
lines changed

5 files changed

+44
-56
lines changed

lib/matplotlib/offsetbox.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,9 @@ def get_extent_offsets(self, renderer):
401401

402402
yoffsets = yoffsets - ydescent
403403

404-
return width + 2 * pad, height + 2 * pad, \
405-
xdescent + pad, ydescent + pad, \
406-
list(zip(xoffsets, yoffsets))
404+
return (width + 2 * pad, height + 2 * pad,
405+
xdescent + pad, ydescent + pad,
406+
list(zip(xoffsets, yoffsets)))
407407

408408

409409
class HPacker(PackerBase):
@@ -479,9 +479,9 @@ def get_extent_offsets(self, renderer):
479479
xdescent = whd_list[0][2]
480480
xoffsets = xoffsets - xdescent
481481

482-
return width + 2 * pad, height + 2 * pad, \
483-
xdescent + pad, ydescent + pad, \
484-
list(zip(xoffsets, yoffsets))
482+
return (width + 2 * pad, height + 2 * pad,
483+
xdescent + pad, ydescent + pad,
484+
list(zip(xoffsets, yoffsets)))
485485

486486

487487
class PaddedBox(OffsetBox):

lib/matplotlib/textpath.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,7 @@ def get_text_path(self, prop, s, ismath=False, usetex=False):
166166
def get_glyphs_with_font(self, font, s, glyph_map=None,
167167
return_new_glyphs_only=False):
168168
"""
169-
convert the string *s* to vertices and codes using the
170-
provided ttf font.
169+
Convert string *s* to vertices and codes using the provided ttf font.
171170
"""
172171

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

203202
glyph = font.load_char(ccode, flags=LOAD_NO_HINTING)
204-
horiz_advance = (glyph.linearHoriAdvance / 65536.0)
203+
horiz_advance = glyph.linearHoriAdvance / 65536
205204

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

210-
currx += (kern / 64.0)
209+
currx += kern / 64
211210

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

224223
return (list(zip(glyph_ids, xpositions, ypositions, sizes)),
225-
glyph_map_new, rects)
224+
glyph_map_new, rects)
226225

227226
def get_glyphs_mathtext(self, prop, s, glyph_map=None,
228227
return_new_glyphs_only=False):

lib/mpl_toolkits/axisartist/clip_path.py

Lines changed: 7 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,8 @@ def clip(xlines, ylines, x0, clip="right", xdir=True, ydir=True):
2626

2727
_pos_angles = []
2828

29-
if xdir:
30-
xsign = 1
31-
else:
32-
xsign = -1
33-
34-
if ydir:
35-
ysign = 1
36-
else:
37-
ysign = -1
38-
29+
xsign = 1 if xdir else -1
30+
ysign = 1 if ydir else -1
3931

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

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

49-
5041
if b[0]:
5142
ns = 0
5243
else:
@@ -56,7 +47,7 @@ def clip(xlines, ylines, x0, clip="right", xdir=True, ydir=True):
5647
c = db[i]
5748
if c == -1:
5849
dx = (x0 - x[i])
59-
dy = (y[i+1] - y[i]) * (dx/ (x[i+1] - x[i]))
50+
dy = (y[i+1] - y[i]) * (dx / (x[i+1] - x[i]))
6051
y0 = y[i] + dy
6152
clipped_xlines.append(np.concatenate([segx, x[ns:i+1], [x0]]))
6253
clipped_ylines.append(np.concatenate([segy, y[ns:i+1], [y0]]))
@@ -88,9 +79,6 @@ def clip(xlines, ylines, x0, clip="right", xdir=True, ydir=True):
8879
clipped_xlines.append(np.concatenate([segx, x[ns:]]))
8980
clipped_ylines.append(np.concatenate([segy, y[ns:]]))
9081

91-
#clipped_pos_angles.append(_pos_angles)
92-
93-
9482
return clipped_xlines, clipped_ylines, _pos_angles
9583

9684

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

124-
#c_left = [((x, y), (a+90)%180-180) for (x, y, a) in c_left_ \
125-
# if bbox.containsy(y)]
126-
c_left = [((x, y), (a+90)%180-90) for (x, y, a) in c_left_
112+
c_left = [((x, y), (a + 90) % 180 - 90) for x, y, a in c_left_
127113
if bbox.containsy(y)]
128-
c_bottom = [((x, y), (90 - a)%180) for (y, x, a) in c_bottom_
114+
c_bottom = [((x, y), (90 - a) % 180) for y, x, a in c_bottom_
129115
if bbox.containsx(x)]
130-
c_right = [((x, y), (a+90)%180+90) for (x, y, a) in c_right_
116+
c_right = [((x, y), (a + 90) % 180 + 90) for x, y, a in c_right_
131117
if bbox.containsy(y)]
132-
c_top = [((x, y), (90 - a)%180+180) for (y, x, a) in c_top_
118+
c_top = [((x, y), (90 - a) % 180 + 180) for y, x, a in c_top_
133119
if bbox.containsx(x)]
134120

135121
return list(zip(lx4, ly4)), [c_left, c_bottom, c_right, c_top]

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
import six
1616
from six.moves import map, zip, reduce
1717

18+
from collections import defaultdict
1819
import math
1920
import warnings
20-
from collections import defaultdict
2121

2222
import numpy as np
2323

@@ -210,17 +210,21 @@ def _init_axis(self):
210210
ax.init3d()
211211

212212
def get_children(self):
213-
return [self.zaxis, ] + super().get_children()
213+
return [self.zaxis] + super().get_children()
214214

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

218218
def unit_cube(self, vals=None):
219219
minx, maxx, miny, maxy, minz, maxz = vals or self.get_w_lims()
220-
xs, ys, zs = ([minx, maxx, maxx, minx, minx, maxx, maxx, minx],
221-
[miny, miny, maxy, maxy, miny, miny, maxy, maxy],
222-
[minz, minz, minz, minz, maxz, maxz, maxz, maxz])
223-
return list(zip(xs, ys, zs))
220+
return [(minx, miny, minz),
221+
(maxx, miny, minz),
222+
(maxx, maxy, minz),
223+
(minx, maxy, minz),
224+
(minx, miny, maxz),
225+
(maxx, miny, maxz),
226+
(maxx, maxy, maxz),
227+
(minx, maxy, maxz)]
224228

225229
def tunit_cube(self, vals=None, M=None):
226230
if M is None:

lib/mpl_toolkits/mplot3d/axis3d.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ def draw(self, renderer):
288288
ax_scale = self.axes.bbox.size / self.figure.bbox.size
289289
ax_inches = np.multiply(ax_scale, self.figure.get_size_inches())
290290
ax_points_estimate = sum(72. * ax_inches)
291-
deltas_per_point = 48. / ax_points_estimate
291+
deltas_per_point = 48 / ax_points_estimate
292292
default_offset = 21.
293293
labeldeltas = (
294294
(self.labelpad + default_offset) * deltas_per_point * deltas)
@@ -305,24 +305,23 @@ def draw(self, renderer):
305305
self.label.set_ha(info['label']['ha'])
306306
self.label.draw(renderer)
307307

308-
309308
# Draw Offset text
310309

311310
# Which of the two edge points do we want to
312311
# use for locating the offset text?
313-
if juggled[2] == 2 :
312+
if juggled[2] == 2:
314313
outeredgep = edgep1
315314
outerindex = 0
316-
else :
315+
else:
317316
outeredgep = edgep2
318317
outerindex = 1
319318

320319
pos = copy.copy(outeredgep)
321320
pos = move_from_center(pos, centers, labeldeltas, axmask)
322321
olx, oly, olz = proj3d.proj_transform(
323322
pos[0], pos[1], pos[2], renderer.M)
324-
self.offsetText.set_text( self.major.formatter.get_offset() )
325-
self.offsetText.set_position( (olx, oly) )
323+
self.offsetText.set_text(self.major.formatter.get_offset())
324+
self.offsetText.set_position((olx, oly))
326325
angle = art3d.norm_text_angle(math.degrees(math.atan2(dy, dx)))
327326
self.offsetText.set_rotation(angle)
328327
# Must set rotation mode to "anchor" so that
@@ -344,29 +343,29 @@ def draw(self, renderer):
344343
# Three-letters (e.g., TFT, FTT) are short-hand for the array of bools
345344
# from the variable 'highs'.
346345
# ---------------------------------------------------------------------
347-
if centpt[info['tickdir']] > peparray[info['tickdir'], outerindex] :
346+
if centpt[info['tickdir']] > peparray[info['tickdir'], outerindex]:
348347
# if FT and if highs has an even number of Trues
349348
if (centpt[index] <= peparray[index, outerindex]
350-
and ((len(highs.nonzero()[0]) % 2) == 0)) :
349+
and len(highs.nonzero()[0]) % 2 == 0):
351350
# Usually, this means align right, except for the FTT case,
352351
# in which offset for axis 1 and 2 are aligned left.
353-
if highs.tolist() == [False, True, True] and index in (1, 2) :
352+
if highs.tolist() == [False, True, True] and index in (1, 2):
354353
align = 'left'
355-
else :
354+
else:
356355
align = 'right'
357-
else :
356+
else:
358357
# The FF case
359358
align = 'left'
360-
else :
359+
else:
361360
# if TF and if highs has an even number of Trues
362361
if (centpt[index] > peparray[index, outerindex]
363-
and ((len(highs.nonzero()[0]) % 2) == 0)) :
362+
and len(highs.nonzero()[0]) % 2 == 0):
364363
# Usually mean align left, except if it is axis 2
365-
if index == 2 :
364+
if index == 2:
366365
align = 'right'
367-
else :
366+
else:
368367
align = 'left'
369-
else :
368+
else:
370369
# The TT case
371370
align = 'right'
372371

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

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

462461
# TODO: Get this to work properly when mplot3d supports
463462
# the transforms framework.
464-
def get_tightbbox(self, renderer) :
463+
def get_tightbbox(self, renderer):
465464
# Currently returns None so that Axis.get_tightbbox
466465
# doesn't return junk info.
467466
return None

0 commit comments

Comments
 (0)
0