Skip to content

Yet another set of simplifications. #11216

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 10, 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/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -1230,18 +1230,18 @@ def __init__(self, x, y, dx, dy, width=0.001, length_includes_head=False,
# start by drawing horizontal arrow, point at (0,0)
hw, hl, hs, lw = head_width, head_length, overhang, width
left_half_arrow = np.array([
[0.0, 0.0], # tip
[-hl, -hw / 2.0], # leftmost
[-hl * (1 - hs), -lw / 2.0], # meets stem
[-length, -lw / 2.0], # bottom left
[0.0, 0.0], # tip
[-hl, -hw / 2], # leftmost
[-hl * (1 - hs), -lw / 2], # meets stem
[-length, -lw / 2], # bottom left
[-length, 0],
])
# if we're not including the head, shift up by head length
if not length_includes_head:
left_half_arrow += [head_length, 0]
# if the head starts at 0, shift up by another head length
if head_starts_at_zero:
left_half_arrow += [head_length / 2.0, 0]
left_half_arrow += [head_length / 2, 0]
# figure out the shape, and complete accordingly
if shape == 'left':
coords = left_half_arrow
Expand All @@ -1266,7 +1266,7 @@ def __init__(self, x, y, dx, dy, width=0.001, length_includes_head=False,
M = [[cx, sx], [-sx, cx]]
verts = np.dot(coords, M) + (x + dx, y + dy)

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


docstring.interpd.update({"FancyArrow": FancyArrow.__init__.__doc__})
Expand Down
22 changes: 9 additions & 13 deletions lib/matplotlib/type1font.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

import binascii
import enum
import io
import itertools
import re
import struct
Expand Down Expand Up @@ -132,11 +131,10 @@ def _split(self, data):
if zeros:
raise RuntimeError('Insufficiently many zeros in Type 1 font')

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

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