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

Skip to content

Commit 7c4b0c3

Browse files
committed
mpl_toolkits style fixes.
1 parent 136d986 commit 7c4b0c3

File tree

7 files changed

+31
-47
lines changed

7 files changed

+31
-47
lines changed

.flake8

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,17 +47,13 @@ per-file-ignores =
4747
lib/matplotlib/tri/triinterpolate.py: E201, E221
4848
lib/matplotlib/type1font.py: E731
4949

50-
lib/mpl_toolkits/axes_grid/axes_rgb.py: E501
5150
lib/mpl_toolkits/axes_grid1/axes_divider.py: E402, E501
52-
lib/mpl_toolkits/axes_grid1/axes_grid.py: E225
53-
lib/mpl_toolkits/axes_grid1/axes_size.py: E272, E501
51+
lib/mpl_toolkits/axes_grid1/axes_size.py: E272
5452
lib/mpl_toolkits/axes_grid1/colorbar.py: E225, E501
55-
lib/mpl_toolkits/axes_grid1/inset_locator.py: E501
5653
lib/mpl_toolkits/axisartist/angle_helper.py: E221
5754
lib/mpl_toolkits/axisartist/clip_path.py: E225
5855
lib/mpl_toolkits/axisartist/floating_axes.py: E225, E402, E501
5956
lib/mpl_toolkits/axisartist/grid_helper_curvelinear.py: E225, E501
60-
lib/mpl_toolkits/tests/test_axes_grid1.py: E201, E202
6157

6258
doc/conf.py: E402, E501
6359
doc/sphinxext/github.py: E302, E501

lib/mpl_toolkits/axes_grid/axes_rgb.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
#from mpl_toolkits.axes_grid1.axes_rgb import *
2-
from mpl_toolkits.axes_grid1.axes_rgb import make_rgb_axes, imshow_rgb, RGBAxesBase
3-
4-
#import mpl_toolkits.axes_grid1.axes_rgb as axes_rgb_orig
1+
from mpl_toolkits.axes_grid1.axes_rgb import (
2+
make_rgb_axes, imshow_rgb, RGBAxesBase)
53
from mpl_toolkits.axisartist.axislines import Axes
64

75

lib/mpl_toolkits/axes_grid1/axes_divider.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
object that can be used to set the axes_locator of the axes.
1111
"""
1212

13-
import matplotlib.transforms as mtransforms
1413
from matplotlib import cbook
1514
from matplotlib.axes import SubplotBase
15+
from matplotlib.gridspec import SubplotSpec, GridSpec
16+
import matplotlib.transforms as mtransforms
1617
from . import axes_size as Size
1718

1819

@@ -347,9 +348,6 @@ def get_subplotspec(self):
347348
return None
348349

349350

350-
from matplotlib.gridspec import SubplotSpec, GridSpec
351-
352-
353351
class SubplotDivider(Divider):
354352
"""
355353
The Divider class whose rectangle area is specified as a subplot geometry.
@@ -539,32 +537,26 @@ def new_horizontal(self, size, pad=None, pack_start=False, **kwargs):
539537
instance of the given class. Otherwise, the same class of the
540538
main axes will be used.
541539
"""
542-
543540
if pad:
544541
if not isinstance(pad, Size._Base):
545-
pad = Size.from_any(pad,
546-
fraction_ref=self._xref)
542+
pad = Size.from_any(pad, fraction_ref=self._xref)
547543
if pack_start:
548544
self._horizontal.insert(0, pad)
549545
self._xrefindex += 1
550546
else:
551547
self._horizontal.append(pad)
552-
553548
if not isinstance(size, Size._Base):
554-
size = Size.from_any(size,
555-
fraction_ref=self._xref)
556-
549+
size = Size.from_any(size, fraction_ref=self._xref)
557550
if pack_start:
558551
self._horizontal.insert(0, size)
559552
self._xrefindex += 1
560553
locator = self.new_locator(nx=0, ny=self._yrefindex)
561554
else:
562555
self._horizontal.append(size)
563-
locator = self.new_locator(nx=len(self._horizontal)-1, ny=self._yrefindex)
564-
556+
locator = self.new_locator(
557+
nx=len(self._horizontal) - 1, ny=self._yrefindex)
565558
ax = self._get_new_axes(**kwargs)
566559
ax.set_axes_locator(locator)
567-
568560
return ax
569561

570562
def new_vertical(self, size, pad=None, pack_start=False, **kwargs):
@@ -589,32 +581,25 @@ def new_vertical(self, size, pad=None, pack_start=False, **kwargs):
589581
instance of the given class. Otherwise, the same class of the
590582
main axes will be used.
591583
"""
592-
593584
if pad:
594585
if not isinstance(pad, Size._Base):
595-
pad = Size.from_any(pad,
596-
fraction_ref=self._yref)
586+
pad = Size.from_any(pad, fraction_ref=self._yref)
597587
if pack_start:
598588
self._vertical.insert(0, pad)
599589
self._yrefindex += 1
600590
else:
601591
self._vertical.append(pad)
602-
603592
if not isinstance(size, Size._Base):
604-
size = Size.from_any(size,
605-
fraction_ref=self._yref)
606-
593+
size = Size.from_any(size, fraction_ref=self._yref)
607594
if pack_start:
608595
self._vertical.insert(0, size)
609596
self._yrefindex += 1
610597
locator = self.new_locator(nx=self._xrefindex, ny=0)
611598
else:
612599
self._vertical.append(size)
613600
locator = self.new_locator(nx=self._xrefindex, ny=len(self._vertical)-1)
614-
615601
ax = self._get_new_axes(**kwargs)
616602
ax.set_axes_locator(locator)
617-
618603
return ax
619604

620605
def append_axes(self, position, size, pad=None, add_to_figure=True,

lib/mpl_toolkits/axes_grid1/axes_grid.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -695,7 +695,7 @@ def _update_locators(self):
695695
(self._colorbar_location == 'right'
696696
and col == self._ncols-1)):
697697
locator = self._divider.new_locator(
698-
nx=h_cb_pos[0], ny=v_ax_pos[self._nrows -1 - row])
698+
nx=h_cb_pos[0], ny=v_ax_pos[self._nrows - 1 - row])
699699
self.cbar_axes[row].set_axes_locator(locator)
700700
elif ((self._colorbar_location == 'bottom' and
701701
row == self._nrows - 1) or

lib/mpl_toolkits/axes_grid1/axes_size.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ def get_size(self, renderer):
5252

5353

5454
class Fixed(_Base):
55-
"Simple fixed size with absolute part = *fixed_size* and relative part = 0"
55+
"""
56+
Simple fixed size with absolute part = *fixed_size* and relative part = 0.
57+
"""
5658
def __init__(self, fixed_size):
5759
self.fixed_size = fixed_size
5860

@@ -63,7 +65,11 @@ def get_size(self, renderer):
6365

6466

6567
class Scaled(_Base):
66-
"Simple scaled(?) size with absolute part = 0 and relative part = *scalable_size*"
68+
"""
69+
Simple scaled(?) size with absolute part = 0 and
70+
relative part = *scalable_size*.
71+
"""
72+
6773
def __init__(self, scalable_size):
6874
self._scalable_size = scalable_size
6975

lib/mpl_toolkits/axes_grid1/inset_locator.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,11 @@ def __init__(self, parent_axes, zoom, loc,
131131
def get_extent(self, renderer):
132132
bb = TransformedBbox(self.axes.viewLim,
133133
self.parent_axes.transData)
134-
135134
x, y, w, h = bb.bounds
136135
fontsize = renderer.points_to_pixels(self.prop.get_size_in_points())
137136
pad = self.pad * fontsize
138-
139-
return abs(w * self.zoom) + 2 * pad, abs(h * self.zoom) + 2 * pad, pad, pad
137+
return (abs(w * self.zoom) + 2 * pad, abs(h * self.zoom) + 2 * pad,
138+
pad, pad)
140139

141140

142141
class BboxPatch(Patch):
@@ -308,7 +307,7 @@ def __init__(self, bbox1, bbox2, loc1, loc2=None, **kwargs):
308307
if 'fill' in kwargs:
309308
Patch.__init__(self, **kwargs)
310309
else:
311-
fill = ('fc' in kwargs) or ('facecolor' in kwargs) or ('color' in kwargs)
310+
fill = bool({'fc', 'facecolor', 'color'}.intersection(kwargs))
312311
Patch.__init__(self, fill=fill, **kwargs)
313312
self.bbox1 = bbox1
314313
self.bbox2 = bbox2
@@ -328,10 +327,10 @@ def __init__(self, bbox1, bbox2, loc1a, loc2a, loc1b, loc2b, **kwargs):
328327
"""
329328
Connect two bboxes with a quadrilateral.
330329
331-
The quadrilateral is specified by two lines that start and end at corners
332-
of the bboxes. The four sides of the quadrilateral are defined by the two
333-
lines given, the line between the two corners specified in *bbox1* and the
334-
line between the two corners specified in *bbox2*.
330+
The quadrilateral is specified by two lines that start and end at
331+
corners of the bboxes. The four sides of the quadrilateral are defined
332+
by the two lines given, the line between the two corners specified in
333+
*bbox1* and the line between the two corners specified in *bbox2*.
335334
336335
Parameters
337336
----------
@@ -666,7 +665,7 @@ def mark_inset(parent_axes, inset_axes, loc1, loc2, **kwargs):
666665
if 'fill' in kwargs:
667666
pp = BboxPatch(rect, **kwargs)
668667
else:
669-
fill = ('fc' in kwargs) or ('facecolor' in kwargs) or ('color' in kwargs)
668+
fill = bool({'fc', 'facecolor', 'color'}.intersection(kwargs))
670669
pp = BboxPatch(rect, fill=fill, **kwargs)
671670
parent_axes.add_patch(pp)
672671

lib/mpl_toolkits/tests/test_axes_grid1.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ def test_twin_axes_empty_and_removed():
7777
matplotlib.rcParams.update({"font.size": 8})
7878
matplotlib.rcParams.update({"xtick.labelsize": 8})
7979
matplotlib.rcParams.update({"ytick.labelsize": 8})
80-
generators = [ "twinx", "twiny", "twin" ]
81-
modifiers = [ "", "host invisible", "twin removed", "twin invisible",
82-
"twin removed\nhost invisible" ]
80+
generators = ["twinx", "twiny", "twin"]
81+
modifiers = ["", "host invisible", "twin removed", "twin invisible",
82+
"twin removed\nhost invisible"]
8383
# Unmodified host subplot at the beginning for reference
8484
h = host_subplot(len(modifiers)+1, len(generators), 2)
8585
h.text(0.5, 0.5, "host_subplot", horizontalalignment="center",

0 commit comments

Comments
 (0)