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 2507f2c

Browse filesBrowse files
authored
Merge pull request #12956 from anntzer/cleanups
MNT: Misc. cleanups.
2 parents d72f069 + 4fcfd4a commit 2507f2c
Copy full SHA for 2507f2c

File tree

Expand file treeCollapse file tree

6 files changed

+13
-22
lines changed
Filter options
Expand file treeCollapse file tree

6 files changed

+13
-22
lines changed

‎examples/text_labels_and_annotations/arrow_demo.py

Copy file name to clipboardExpand all lines: examples/text_labels_and_annotations/arrow_demo.py
+3-6Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,16 @@ def do_fontsize(k):
147147

148148
if normalize_data:
149149
# find maximum value for rates, i.e. where keys are 2 chars long
150-
max_val = 0
151-
for k, v in data.items():
152-
if len(k) == 2:
153-
max_val = max(max_val, v)
150+
max_val = max((v for k, v in data.items() if len(k) == 2), default=0)
154151
# divide rates by max val, multiply by arrow scale factor
155152
for k, v in data.items():
156153
data[k] = v / max_val * sf
157154

158155
def draw_arrow(pair, alpha=alpha, ec=ec, labelcolor=labelcolor):
159156
# set the length of the arrow
160157
if display == 'length':
161-
length = max_head_length + data[pair] / sf * (max_arrow_length -
162-
max_head_length)
158+
length = (max_head_length
159+
+ data[pair] / sf * (max_arrow_length - max_head_length))
163160
else:
164161
length = max_arrow_length
165162
# set the transparency of the arrow

‎lib/matplotlib/backends/backend_pdf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_pdf.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,7 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
18961896
fontsize = prop.get_size_in_points()
18971897
dvifile = texmanager.make_dvi(s, fontsize)
18981898
with dviread.Dvi(dvifile, 72) as dvi:
1899-
page = next(iter(dvi))
1899+
page, = dvi
19001900

19011901
# Gather font information and do some setup for combining
19021902
# characters into strings. The variable seq will contain a

‎lib/matplotlib/lines.py

Copy file name to clipboardExpand all lines: lib/matplotlib/lines.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -657,7 +657,7 @@ def set_data(self, *args):
657657
*args : (N, 2) array or two 1D arrays
658658
"""
659659
if len(args) == 1:
660-
x, y = args[0]
660+
(x, y), = args
661661
else:
662662
x, y = args
663663

@@ -763,8 +763,8 @@ def draw(self, renderer):
763763
self.ind_offset = 0 # Needed for contains() method.
764764
if self._subslice and self.axes:
765765
x0, x1 = self.axes.get_xbound()
766-
i0, = self._x_filled.searchsorted([x0], 'left')
767-
i1, = self._x_filled.searchsorted([x1], 'right')
766+
i0 = self._x_filled.searchsorted(x0, 'left')
767+
i1 = self._x_filled.searchsorted(x1, 'right')
768768
subslice = slice(max(i0 - 1, 0), i1 + 1)
769769
self.ind_offset = subslice.start
770770
self._transform_path(subslice)

‎lib/matplotlib/style/core.py

Copy file name to clipboardExpand all lines: lib/matplotlib/style/core.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ def iter_style_files(style_dir):
178178
if is_style_file(filename):
179179
match = STYLE_FILE_PATTERN.match(filename)
180180
path = os.path.abspath(os.path.join(style_dir, path))
181-
yield path, match.groups()[0]
181+
yield path, match.group(1)
182182

183183

184184
def read_style_directory(style_dir):

‎lib/matplotlib/table.py

Copy file name to clipboardExpand all lines: lib/matplotlib/table.py
+4-10Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -518,17 +518,11 @@ def auto_set_column_width(self, col):
518518

519519
def _auto_set_column_width(self, col, renderer):
520520
"""Automatically set width for column."""
521-
cells = [key for key in self._cells if key[1] == col]
522-
523-
# find max width
524-
width = 0
525-
for cell in cells:
526-
c = self._cells[cell]
527-
width = max(c.get_required_width(renderer), width)
528-
529-
# Now set the widths
521+
cells = [cell for key, cell in self._cells.items() if key[1] == col]
522+
max_width = max((cell.get_required_width(renderer) for cell in cells),
523+
default=0)
530524
for cell in cells:
531-
self._cells[cell].set_width(width)
525+
cell.set_width(max_width)
532526

533527
def auto_set_font_size(self, value=True):
534528
""" Automatically set font size. """

‎lib/matplotlib/texmanager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/texmanager.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,6 @@ def get_text_width_height_descent(self, tex, fontsize, renderer=None):
463463
# use dviread. It sometimes returns a wrong descent.
464464
dvifile = self.make_dvi(tex, fontsize)
465465
with dviread.Dvi(dvifile, 72 * dpi_fraction) as dvi:
466-
page = next(iter(dvi))
466+
page, = dvi
467467
# A total height (including the descent) needs to be returned.
468468
return page.width, page.height + page.descent, page.descent

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.