8000 Merge pull request #14018 from anntzer/morepep8 · matplotlib/matplotlib@01ad461 · GitHub
[go: up one dir, main page]

Skip to content

Commit 01ad461

Browse files
authored
Merge pull request #14018 from anntzer/morepep8
pep8ing.
2 parents 4ce649c + af89a6a commit 01ad461

File tree

4 files changed

+128
-142
lines changed

4 files changed

+128
-142
lines changed

.flake8

Lines changed: 1 addition & 3 deletions
10000
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,11 @@ per-file-ignores =
3636
lib/matplotlib/_cm.py: E202, E203, E302
3737
lib/matplotlib/_mathtext_data.py: E203, E261
3838
lib/matplotlib/font_manager.py: E203, E221, E251, E501
39-
lib/matplotlib/fontconfig_pattern.py: E201, E203, E221, E222, E225
4039
lib/matplotlib/mathtext.py: E201, E202, E203, E211, E221, E222, E225, E251, E301, E402
41-
lib/matplotlib/projections/geo.py: E203, E221, E502
4240
lib/matplotlib/pylab.py: E501
4341
lib/matplotlib/rcsetup.py: E501
4442
lib/matplotlib/tests/test_mathtext.py: E501
45-
lib/matplotlib/transforms.py: E201, E202, E203, E501
43+
lib/matplotlib/transforms.py: E201, E202, E203
4644
lib/matplotlib/tri/triinterpolate.py: E201, E221
4745

4846
lib/mpl_toolkits/axes_grid1/axes_divider.py: E402, E501

lib/matplotlib/fontconfig_pattern.py

Lines changed: 76 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -36,76 +36,85 @@ class FontconfigPatternParser(object):
3636
"""
3737

3838
_constants = {
39-
'thin' : ('weight', 'light'),
40-
'extralight' : ('weight', 'light'),
41-
'ultralight' : ('weight', 'light'),
42-
'light' : ('weight', 'light'),
43-
'book' : ('weight', 'book'),
44-
'regular' : ('weight', 'regular'),
45-
'normal' : ('weight', 'normal'),
46-
'medium' : ('weight', 'medium'),
47-
'demibold' : ('weight', 'demibold'),
48-
'semibold' : ('weight', 'semibold'),
49-
'bold' : ('weight', 'bold'),
50-
'extrabold' : ('weight', 'extra bold'),
51-
'black' : ('weight', 'black'),
52-
'heavy' : ('weight', 'heavy'),
53-
'roman' : ('slant', 'normal'),
54-
'italic' : ('slant', 'italic'),
55-
'oblique' : ('slant', 'oblique'),
56-
'ultracondensed' : ('width', 'ultra-condensed'),
57-
'extracondensed' : ('width', 'extra-condensed'),
58-
'condensed' : ('width', 'condensed'),
59-
'semicondensed' : ('width', 'semi-condensed'),
60-
'expanded' : ('width', 'expanded'),
61-
'extraexpanded' : ('width', 'extra-expanded'),
62-
'ultraexpanded' : ('width', 'ultra-expanded')
39+
'thin': ('weight', 'light'),
40+
'extralight': ('weight', 'light'),
41+
'ultralight': ('weight', 'light'),
42+
'light': ('weight', 'light'),
43+
'book': ('weight', 'book'),
44+
'regular': ('weight', 'regular'),
45+
'normal': ('weight', 'normal'),
46+
'medium': ('weight', 'medium'),
47+
'demibold': ('weight', 'demibold'),
48+
'semibold': ('weight', 'semibold'),
49+
'bold': ('weight', 'bold'),
50+
'extrabold': ('weight', 'extra bold'),
51+
'black': ('weight', 'black'),
52+
'heavy': ('weight', 'heavy'),
53+
'roman': ('slant', 'normal'),
54+
'italic': ('slant', 'italic'),
55+
'oblique': ('slant', 'oblique'),
56+
'ultracondensed': ('width', 'ultra-condensed'),
57+
'extracondensed': ('width', 'extra-condensed'),
58+
'condensed': ('width', 'condensed'),
59+
'semicondensed': ('width', 'semi-condensed'),
60+
'expanded': ('width', 'expanded'),
61+
'extraexpanded': ('width', 'extra-expanded'),
62+
'ultraexpanded': ('width', 'ultra-expanded')
6363
}
6464

6565
def __init__(self):
66-
family = Regex(r'([^%s]|(\\[%s]))*' %
67-
(family_punc, family_punc)) \
68-
.setParseAction(self._family)
69-
size = Regex(r"([0-9]+\.?[0-9]*|\.[0-9]+)") \
70-
.setParseAction(self._size)
71-
name = Regex(r'[a-z]+') \
72-
.setParseAction(self._name)
73-
value = Regex(r'([^%s]|(\\[%s]))*' %
74-
(value_punc, value_punc)) \
75-
.setParseAction(self._value)
76-
77-
families = (family
78-
+ ZeroOrMore(
79-
Literal(',')
80-
+ family)
81-
).setParseAction(self._families)
82-
83-
point_sizes = (size
84-
+ ZeroOrMore(
85-
Literal(',')
86-
+ size)
87-
).setParseAction(self._point_sizes)
88-
89-
property = ((name
90-
+ Suppress(Literal('='))
91-
+ value
92-
+ ZeroOrMore(
93-
Suppress(Literal(','))
94-
+ value)
95-
)
96-
| name
97-
).setParseAction(self._property)
98-
99-
pattern = (Optional(
100-
families)
101-
+ Optional(
102-
Literal('-')
103-
+ point_sizes)
104-
+ ZeroOrMore(
105-
Literal(':')
106-
+ property)
107-
+ StringEnd()
108-
)
66+
67+
family = Regex(
68+
r'([^%s]|(\\[%s]))*' % (family_punc, family_punc)
69+
).setParseAction(self._family)
70+
71+
size = Regex(
72+
r"([0-9]+\.?[0-9]*|\.[0-9]+)"
73+
).setParseAction(self._size)
74+
75+
name = Regex(
76+
r'[a-z]+'
77+
).setParseAction(self._name)
78+
79+
value = Regex(
80+
r'([^%s]|(\\[%s]))*' % (value_punc, value_punc)
81+
).setParseAction(self._value)
82+
83+
families = (
84+
family
85+
+ ZeroOrMore(
86+
Literal(',')
87+
+ family)
88+
).setParseAction(self._families)
89+
90+
point_sizes = (
91+
size
92+
+ ZeroOrMore(
93+
Literal(',')
94+
+ size)
95+
).setParseAction(self._point_sizes)
96+
97+
property = (
98+
(name
99+
+ Suppress(Literal('='))
100+
+ value
101+
+ ZeroOrMore(
102+
Suppress(Literal(','))
103+
+ value))
104+
| name
105+
).setParseAction(self._property)
106+
107+
pattern = (
108+
Optional(
109+
families)
110+
+ Optional(
111+
Literal('-')
112+
+ point_sizes)
113+
+ ZeroOrMore(
114+
Literal(':')
115+
+ property)
116+
+ StringEnd()
117+
)
109118

110119
self._parser = pattern
111120
self.ParseException = ParseException

lib/matplotlib/projections/geo.py

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ def _set_lim_and_transforms(self):
9999
yaxis_text_base = \
100100
yaxis_stretch + \
101101
self.transProjection + \
102-
(yaxis_space + \
103-
self.transAffine + \
102+
(yaxis_space +
103+
self.transAffine +
104104
self.transAxes)
105105
self._yaxis_text1_transform = \
106106
yaxis_text_base + \
@@ -214,7 +214,7 @@ def can_zoom(self):
214214
"""
215215
return False
216216

217-
def can_pan(self) :
217+
def can_pan(self):
218218
"""
219219
Return *True* if this axes supports the pan/zoom button functionality.
220220
@@ -316,18 +316,14 @@ class HammerTransform(_GeoTransform):
316316

317317
def transform_non_affine(self, ll):
318318
# docstring inherited
319-
longitude = ll[:, 0:1]
320-
latitude = ll[:, 1:2]
321-
322-
# Pre-compute some values
319+
longitude, latitude = ll.T
323320
half_long = longitude / 2.0
324321
cos_latitude = np.cos(latitude)
325322
sqrt2 = np.sqrt(2.0)
326-
327323
alpha = np.sqrt(1.0 + cos_latitude * np.cos(half_long))
328324
x = (2.0 * sqrt2) * (cos_latitude * np.sin(half_long)) / alpha
329325
y = (sqrt2 * np.sin(latitude)) / alpha
330-
return np.concatenate((x, y), 1)
326+
return np.column_stack([x, y])
331327

332328
def inverted(self):
333329
# docstring inherited
@@ -370,8 +366,7 @@ def d(theta):
370366
/ (1 + np.cos(theta)))
371367
return delta, np.abs(delta) > 0.001
372368

373-
longitude = ll[:, 0]
374-
latitude = ll[:, 1]
369+
longitude, latitude = ll.T
375370

376371
clat = np.pi/2 - np.abs(latitude)
377372
ihigh = clat < 0.087 # within 5 degrees of the poles
@@ -406,16 +401,13 @@ class InvertedMollweideTransform(_GeoTransform):
406401

407402
def transform_non_affine(self, xy):
408403
# docstring inherited
409-
x = xy[:, 0:1]
410-
y = xy[:, 1:2]
411-
404+
x, y = xy.T
412405
# from Equations (7, 8) of
413406
# http://mathworld.wolfram.com/MollweideProjection.html
414407
theta = np.arcsin(y / np.sqrt(2))
415408
lon = (np.pi / (2 * np.sqrt(2))) * x / np.cos(theta)
416409
lat = np.arcsin((2 * theta + np.sin(2 * theta)) / np.pi)
417-
418-
return np.concatenate((lon, lat), 1)
410+
return np.column_stack([lon, lat])
419411

420412
def inverted(self):
421413
# docstring inherited
@@ -449,8 +441,7 @@ def __init__(self, center_longitude, center_latitude, resolution):
449441

450442
def transform_non_affine(self, ll):
451443
# docstring inherited
452-
longitude = ll[:, 0:1]
453-
latitude = ll[:, 1:2]
444+
longitude, latitude = ll.T
454445
clong = self._center_longitude
455446
clat = self._center_latitude
456447
cos_lat = np.cos(latitude)
@@ -465,7 +456,7 @@ def transform_non_affine(self, ll):
465456
x = k * cos_lat*np.sin(diff_long)
466457
y = k * (np.cos(clat)*sin_lat - np.sin(clat)*cos_lat*cos_diff_long)
467458

468-
return np.concatenate((x, y), 1)
459+
return np.column_stack([x, y])
469460

470461
def inverted(self):
471462
# docstring inherited

0 commit comments

Comments
 (0)
0