Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6286e63

Browse files
authored
Merge pull request matplotlib#11216 from anntzer/cleanups3
Yet another set of simplifications.
2 parents 46f8cad + be3d969 commit 6286e63

File tree

2 files changed

+15
-19
lines changed

2 files changed

+15
-19
lines changed

lib/matplotlib/patches.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,18 +1230,18 @@ def __init__(self, x, y, dx, dy, width=0.001, length_includes_head=False,
12301230
# start by drawing horizontal arrow, point at (0,0)
12311231
hw, hl, hs, lw = head_width, head_length, overhang, width
12321232
left_half_arrow = np.array([
1233-
[0.0, 0.0], # tip
1234-
[-hl, -hw / 2.0], # leftmost
1235-
[-hl * (1 - hs), -lw / 2.0], # meets stem
1236-
[-length, -lw / 2.0], # bottom left
1233+
[0.0, 0.0], # tip
1234+
[-hl, -hw / 2], # leftmost
1235+
[-hl * (1 - hs), -lw / 2], # meets stem
1236+
[-length, -lw / 2], # bottom left
12371237
[-length, 0],
12381238
])
12391239
# if we're not including the head, shift up by head length
12401240
if not length_includes_head:
12411241
left_half_arrow += [head_length, 0]
12421242
# if the head starts at 0, shift up by another head length
12431243
if head_starts_at_zero:
1244-
left_half_arrow += [head_length / 2.0, 0]
1244+
left_half_arrow += [head_length / 2, 0]
12451245
# figure out the shape, and complete accordingly
12461246
if shape == 'left':
12471247
coords = left_half_arrow
@@ -1266,7 +1266,7 @@ def __init__(self, x, y, dx, dy, width=0.001, length_includes_head=False,
12661266
M = [[cx, sx], [-sx, cx]]
12671267
verts = np.dot(coords, M) + (x + dx, y + dy)
12681268

1269-
Polygon.__init__(self, list(map(tuple, verts)), closed=True, **kwargs)
1269+
super().__init__(verts, closed=True, **kwargs)
12701270

12711271

12721272
docstring.interpd.update({"FancyArrow": FancyArrow.__init__.__doc__})

lib/matplotlib/type1font.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import binascii
2828
import enum
29-
import io
3029
import itertools
3130
import re
3231
import struct
@@ -132,11 +131,10 @@ def _split(self, data):
132131
if zeros:
133132
raise RuntimeError('Insufficiently many zeros in Type 1 font')
134133

135-
# Convert encrypted part to binary (if we read a pfb file, we
136-
# may end up converting binary to hexadecimal to binary again;
137-
# but if we read a pfa file, this part is already in hex, and
138-
# I am not quite sure if even the pfb format guarantees that
139-
# it will be in binary).
134+
# Convert encrypted part to binary (if we read a pfb file, we may end
135+
# up converting binary to hexadecimal to binary again; but if we read
136+
# a pfa file, this part is already in hex, and I am not quite sure if
137+
# even the pfb format guarantees that it will be in binary).
140138
binary = binascii.unhexlify(data[len1:idx+1])
141139

142140
return data[:len1], binary, data[idx+1:]
@@ -321,10 +319,8 @@ def transform(self, effects):
321319
multiplier by which the font is to be extended (so values less
322320
than 1.0 condense). Returns a new :class:`Type1Font` object.
323321
"""
324-
with io.BytesIO() as buffer:
325-
tokenizer = self._tokens(self.parts[0])
326-
transformed = self._transformer(tokenizer,
327-
slant=effects.get('slant', 0.0),
328-
extend=effects.get('extend', 1.0))
329-
list(map(buffer.write, transformed))
330-
return Type1Font((buffer.getvalue(), self.parts[1], self.parts[2]))
322+
tokenizer = self._tokens(self.parts[0])
323+
transformed = self._transformer(tokenizer,
324+
slant=effects.get('slant', 0.0),
325+
extend=effects.get('extend', 1.0))
326+
return Type1Font((b"".join(transformed), self.parts[1], self.parts[2]))

0 commit comments

Comments
 (0)