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

Skip to content

Commit 34aee94

Browse files
authored
Merge pull request #10569 from anntzer/style
Various style fixes.
2 parents 59c39ed + 441a6bc commit 34aee94

27 files changed

Lines changed: 100 additions & 159 deletions

examples/event_handling/ginput_manual_clabel_sgskip.py

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ def tellme(s):
4040

4141
plt.waitforbuttonpress()
4242

43-
happy = False
44-
while not happy:
43+
while True:
4544
pts = []
4645
while len(pts) < 3:
4746
tellme('Select 3 corners with mouse')
@@ -54,12 +53,12 @@ def tellme(s):
5453

5554
tellme('Happy? Key click for yes, mouse click for no')
5655

57-
happy = plt.waitforbuttonpress()
56+
if plt.waitforbuttonpress():
57+
break
5858

5959
# Get rid of fill
60-
if not happy:
61-
for p in ph:
62-
p.remove()
60+
for p in ph:
61+
p.remove()
6362

6463

6564
##################################################
@@ -88,13 +87,11 @@ def f(x, y, pts):
8887
tellme('Now do a nested zoom, click to begin')
8988
plt.waitforbuttonpress()
9089

91-
happy = False
92-
while not happy:
90+
while True:
9391
tellme('Select two corners of zoom, middle mouse button to finish')
9492
pts = np.asarray(plt.ginput(2, timeout=-1))
9593

96-
happy = len(pts) < 2
97-
if happy:
94+
if len(pts) < 2:
9895
break
9996

10097
pts = np.sort(pts, axis=0)

lib/matplotlib/afm.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,8 @@ def _parse_header(fh):
162162
try:
163163
d[key] = headerConverters[key](val)
164164
except ValueError:
165-
print('Value error parsing header in AFM:',
166-
key, val, file=sys.stderr)
165+
print('Value error parsing header in AFM:', key, val,
166+
file=sys.stderr)
167167
continue
168168
except KeyError:
169169
print('Found an unknown keyword in AFM header (was %r)' % key,

lib/matplotlib/animation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -761,11 +761,11 @@ def _init_from_registry(cls):
761761
for flag in (0, winreg.KEY_WOW64_32KEY, winreg.KEY_WOW64_64KEY):
762762
try:
763763
hkey = winreg.OpenKeyEx(winreg.HKEY_LOCAL_MACHINE,
764-
'Software\\Imagemagick\\Current',
764+
r'Software\Imagemagick\Current',
765765
0, winreg.KEY_QUERY_VALUE | flag)
766766
binpath = winreg.QueryValueEx(hkey, 'BinPath')[0]
767767
winreg.CloseKey(hkey)
768-
binpath += '\\convert.exe'
768+
binpath += r'\convert.exe'
769769
break
770770
except Exception:
771771
binpath = ''

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ def _init_toolbar(self):
507507

508508
for text, tooltip_text, image_file, callback in self.toolitems:
509509
if text is None:
510-
self.insert( Gtk.SeparatorToolItem(), -1 )
510+
self.insert(Gtk.SeparatorToolItem(), -1)
511511
continue
512512
fname = os.path.join(basedir, image_file + '.png')
513513
image = Gtk.Image()
@@ -654,14 +654,10 @@ def cb_cbox_changed (cbox, data=None):
654654
self.set_extra_widget(hbox)
655655

656656
def get_filename_from_user (self):
657-
while True:
658-
filename = None
659-
if self.run() != int(Gtk.ResponseType.OK):
660-
break
661-
filename = self.get_filename()
662-
break
663-
664-
return filename, self.ext
657+
if self.run() == int(Gtk.ResponseType.OK):
658+
return self.get_filename(), self.ext
659+
else:
660+
return None, self.ext
665661

666662

667663
class RubberbandGTK3(backend_tools.RubberbandBase):

lib/matplotlib/backends/backend_pdf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1804,8 +1804,8 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans,
18041804
simplify=False):
18051805
if len(vertices):
18061806
x, y = vertices[-2:]
1807-
if (x < 0 or y < 0 or
1808-
x > self.file.width * 72 or y > self.file.height * 72):
1807+
if not (0 <= x <= self.file.width * 72
1808+
and 0 <= y <= self.file.height * 72):
18091809
continue
18101810
dx, dy = x - lastx, y - lasty
18111811
output(1, 0, 0, 1, dx, dy, Op.concat_matrix,

lib/matplotlib/backends/backend_ps.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,16 @@ def supports_ps2write(self):
129129
'b10': (1.26,1.76)}
130130

131131
def _get_papertype(w, h):
132-
keys = list(six.iterkeys(papersize))
133-
keys.sort()
134-
keys.reverse()
135-
for key in keys:
136-
if key.startswith('l'): continue
137-
pw, ph = papersize[key]
138-
if (w < pw) and (h < ph): return key
132+
for key, (pw, ph) in sorted(papersize.items(), reverse=True):
133+
if key.startswith('l'):
134+
continue
135+
if w < pw and h < ph:
136+
return key
139137
return 'a0'
140138

141139
def _num_to_str(val):
142-
if isinstance(val, six.string_types): return val
140+
if isinstance(val, six.string_types):
141+
return val
143142

144143
ival = int(val)
145144
if val == ival: return str(ival)

lib/matplotlib/backends/backend_svg.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,15 +231,12 @@ def generate_transform(transform_list=[]):
231231
if len(transform_list):
232232
output = io.StringIO()
233233
for type, value in transform_list:
234-
if type == 'scale' and (value == (1.0,) or value == (1.0, 1.0)):
235-
continue
236-
if type == 'translate' and value == (0.0, 0.0):
237-
continue
238-
if type == 'rotate' and value == (0.0,):
234+
if (type == 'scale' and (value == (1,) or value == (1, 1))
235+
or type == 'translate' and value == (0, 0)
236+
or type == 'rotate' and value == (0,)):
239237
continue
240238
if type == 'matrix' and isinstance(value, Affine2DBase):
241239
value = value.to_values()
242-
243240
output.write('%s(%s)' % (
244241
type, ' '.join(short_float_fmt(x) for x in value)))
245242
return output.getvalue()

lib/matplotlib/backends/backend_webagg.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,6 @@ def random_ports(port, n):
237237
for i in range(n - 5):
238238
yield port + random.randint(-2 * n, 2 * n)
239239

240-
success = None
241-
242240
if address is None:
243241
cls.address = rcParams['webagg.address']
244242
else:
@@ -252,10 +250,8 @@ def random_ports(port, n):
252250
raise
253251
else:
254252
cls.port = port
255-
success = True
256253
break
257-
258-
if not success:
254+
else:
259255
raise SystemExit(
260256
"The webagg server could not be started because an available "
261257
"port could not be found")

lib/matplotlib/cbook/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,9 +1255,7 @@ def remove(self, o):
12551255
old = self._elements[:]
12561256
self.clear()
12571257
for thiso in old:
1258-
if thiso == o:
1259-
continue
1260-
else:
1258+
if thiso != o:
12611259
self.push(thiso)
12621260

12631261

lib/matplotlib/colorbar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1388,7 +1388,7 @@ def colorbar_factory(cax, mappable, **kwargs):
13881388
# if the given mappable is a contourset with any hatching, use
13891389
# ColorbarPatch else use Colorbar
13901390
if (isinstance(mappable, contour.ContourSet)
1391-
and any([hatch is not None for hatch in mappable.hatches])):
1391+
and any(hatch is not None for hatch in mappable.hatches)):
13921392
cb = ColorbarPatch(cax, mappable, **kwargs)
13931393
else:
13941394
cb = Colorbar(cax, mappable, **kwargs)

0 commit comments

Comments
 (0)