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 48584c7

Browse filesBrowse files
authored
Merge pull request #8603 from QuLogic/pep8
Cleanup examples and re-enable pep8
2 parents c3e24eb + f0d9ca0 commit 48584c7
Copy full SHA for 48584c7

File tree

Expand file treeCollapse file tree

75 files changed

+300
-393
lines changed
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree

75 files changed

+300
-393
lines changed

‎ci/travis/test_script.sh

Copy file name to clipboardExpand all lines: ci/travis/test_script.sh
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#! /bin/bash
22

3-
set -e
3+
set -ev
44

55
# This script is meant to be called by the "script" step defined in
66
# .travis.yml. See http://docs.travis-ci.com/ for more details.
@@ -26,9 +26,9 @@ if [[ $BUILD_DOCS == false ]]; then
2626

2727
echo The following args are passed to pytest $PYTEST_ARGS $RUN_PEP8
2828
if [[ $TRAVIS_OS_NAME == 'osx' ]]; then
29-
python tests.py $PYTEST_ARGS $RUN_PEP8
29+
pytest $PYTEST_ARGS $RUN_PEP8
3030
else
31-
gdb -return-child-result -batch -ex r -ex bt --args python $PYTHON_ARGS tests.py $PYTEST_ARGS $RUN_PEP8
31+
gdb -return-child-result -batch -ex r -ex bt --args python $PYTHON_ARGS -m pytest $PYTEST_ARGS $RUN_PEP8
3232
fi
3333
else
3434
cd doc

‎examples/axes_grid1/demo_colorbar_of_inset_axes.py

Copy file name to clipboardExpand all lines: examples/axes_grid1/demo_colorbar_of_inset_axes.py
+7-10Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
from mpl_toolkits.axes_grid1.inset_locator import inset_axes, zoomed_inset_axes
1010
from mpl_toolkits.axes_grid1.colorbar import colorbar
1111

12+
1213
def get_demo_image():
1314
from matplotlib.cbook import get_sample_data
1415
import numpy as np
1516
f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False)
1617
z = np.load(f)
1718
# z is a numpy array of 15x15
18-
return z, (-3,4,-4,3)
19+
return z, (-3, 4, -4, 3)
1920

2021

21-
fig = plt.figure(1, [5,4])
22-
ax = fig.add_subplot(111)
22+
fig, ax = plt.subplots(figsize=[5, 4])
2323

2424
Z, extent = get_demo_image()
2525

@@ -28,7 +28,7 @@ def get_demo_image():
2828
ylim=(-20, 5))
2929

3030

31-
axins = zoomed_inset_axes(ax, 2, loc=2) # zoom = 6
31+
axins = zoomed_inset_axes(ax, 2, loc=2) # zoom = 6
3232
im = axins.imshow(Z, extent=extent, interpolation="nearest",
3333
origin="lower")
3434

@@ -38,17 +38,14 @@ def get_demo_image():
3838

3939
# colorbar
4040
cax = inset_axes(axins,
41-
width="5%", # width = 10% of parent_bbox width
42-
height="100%", # height : 50%
41+
width="5%", # width = 10% of parent_bbox width
42+
height="100%", # height : 50%
4343
loc=3,
4444
bbox_to_anchor=(1.05, 0., 1, 1),
4545
bbox_transform=axins.transAxes,
4646
borderpad=0,
4747
)
4848

49+
colorbar(im, cax=cax)
4950

50-
colorbar(im, cax=cax) #, ticks=[1,2,3])
51-
52-
53-
plt.draw()
5451
plt.show()

‎examples/axes_grid1/demo_colorbar_with_axes_divider.py

Copy file name to clipboardExpand all lines: examples/axes_grid1/demo_colorbar_with_axes_divider.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
fig.subplots_adjust(wspace=0.5)
1515

1616
ax1 = fig.add_subplot(121)
17-
im1 = ax1.imshow([[1,2],[3,4]])
17+
im1 = ax1.imshow([[1, 2], [3, 4]])
1818

1919
ax1_divider = make_axes_locatable(ax1)
2020
cax1 = ax1_divider.append_axes("right", size="7%", pad="2%")
2121
cb1 = colorbar(im1, cax=cax1)
2222

2323
ax2 = fig.add_subplot(122)
24-
im2 = ax2.imshow([[1,2],[3,4]])
24+
im2 = ax2.imshow([[1, 2], [3, 4]])
2525

2626
ax2_divider = make_axes_locatable(ax2)
2727
cax2 = ax2_divider.append_axes("top", size="7%", pad="2%")

‎examples/axes_grid1/demo_fixed_size_axes.py

Copy file name to clipboardExpand all lines: examples/axes_grid1/demo_fixed_size_axes.py
+7-15Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88

99
from mpl_toolkits.axes_grid1 import Divider, LocatableAxes, Size
1010

11-
def demo_fixed_size_axes():
1211

12+
def demo_fixed_size_axes():
1313
fig1 = plt.figure(1, (6, 6))
1414

1515
# The first items are for padding and the second items are for the axes.
@@ -25,19 +25,16 @@ def demo_fixed_size_axes():
2525

2626
fig1.add_axes(ax)
2727

28-
ax.plot([1,2,3])
29-
30-
28+
ax.plot([1, 2, 3])
3129

3230

3331
def demo_fixed_pad_axes():
34-
3532
fig = plt.figure(2, (6, 6))
3633

37-
# The first & third items are for padding and the second items are for the axes.
38-
# sizes are in inch.
39-
h = [Size.Fixed(1.0), Size.Scaled(1.), Size.Fixed(.2),]
40-
v = [Size.Fixed(0.7), Size.Scaled(1.), Size.Fixed(.5),]
34+
# The first & third items are for padding and the second items are for the
35+
# axes. Sizes are in inches.
36+
h = [Size.Fixed(1.0), Size.Scaled(1.), Size.Fixed(.2)]
37+
v = [Size.Fixed(0.7), Size.Scaled(1.), Size.Fixed(.5)]
4138

4239
divider = Divider(fig, (0.0, 0.0, 1., 1.), h, v, aspect=False)
4340
# the width and height of the rectangle is ignored.
@@ -47,16 +44,11 @@ def demo_fixed_pad_axes():
4744

4845
fig.add_axes(ax)
4946

50-
ax.plot([1,2,3])
51-
52-
53-
54-
47+
ax.plot([1, 2, 3])
5548

5649

5750
if __name__ == "__main__":
5851
demo_fixed_size_axes()
5952
demo_fixed_pad_axes()
6053

61-
plt.draw()
6254
plt.show()

‎examples/axes_grid1/demo_new_colorbar.py

Copy file name to clipboardExpand all lines: examples/axes_grid1/demo_new_colorbar.py
+8-9Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,20 @@
55
66
"""
77
import matplotlib.pyplot as plt
8+
from mpl_toolkits.axes_grid1.colorbar import colorbar
9+
810

9-
plt.rcParams["text.usetex"]=False
11+
plt.rcParams["text.usetex"] = False
1012

11-
fig = plt.figure(1, figsize=(6, 3))
13+
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(6, 3))
1214

13-
ax1 = fig.add_subplot(121)
14-
im1 = ax1.imshow([[1,2],[3,4]])
15-
cb1 = plt.colorbar(im1)
15+
im1 = ax1.imshow([[1, 2], [3, 4]])
16+
cb1 = fig.colorbar(im1, ax=ax1)
1617
cb1.ax.set_yticks([1, 3])
1718
ax1.set_title("Original MPL's colorbar w/\nset_yticks([1,3])", size=10)
1819

19-
from mpl_toolkits.axes_grid1.colorbar import colorbar
20-
ax2 = fig.add_subplot(122)
21-
im2 = ax2.imshow([[1,2],[3,4]])
22-
cb2 = colorbar(im2)
20+
im2 = ax2.imshow([[1, 2], [3, 4]])
21+
cb2 = colorbar(im2, ax=ax2)
2322
cb2.ax.set_yticks([1, 3])
2423
ax2.set_title("AxesGrid's colorbar w/\nset_yticks([1,3])", size=10)
2524

‎examples/axes_grid1/parasite_simple.py

Copy file name to clipboardExpand all lines: examples/axes_grid1/parasite_simple.py
-1Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,3 @@
2727
leg.texts[1].set_color(p2.get_color())
2828

2929
plt.show()
30-

‎examples/axes_grid1/simple_axes_divider1.py

Copy file name to clipboardExpand all lines: examples/axes_grid1/simple_axes_divider1.py
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,4 @@
3030
ax3.set_axes_locator(divider.new_locator(nx=2, ny=2))
3131
ax4.set_axes_locator(divider.new_locator(nx=2, nx1=4, ny=0))
3232

33-
34-
plt.draw()
3533
plt.show()

‎examples/axes_grid1/simple_axes_divider2.py

Copy file name to clipboardExpand all lines: examples/axes_grid1/simple_axes_divider2.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
# the rect parameter will be ignore as we will set axes_locator
1414
rect = (0.1, 0.1, 0.8, 0.8)
15-
ax = [fig1.add_axes(rect, label="%d"%i) for i in range(4)]
15+
ax = [fig1.add_axes(rect, label="%d" % i) for i in range(4)]
1616

1717
horiz = [Size.Scaled(1.5), Size.Fixed(.5), Size.Scaled(1.),
1818
Size.Scaled(.5)]
@@ -31,5 +31,4 @@
3131
plt.setp(ax1.get_xticklabels()+ax1.get_yticklabels(),
3232
visible=False)
3333

34-
plt.draw()
3534
plt.show()

‎examples/axes_grid1/simple_axes_divider3.py

Copy file name to clipboardExpand all lines: examples/axes_grid1/simple_axes_divider3.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
# the rect parameter will be ignore as we will set axes_locator
1515
rect = (0.1, 0.1, 0.8, 0.8)
16-
ax = [fig1.add_axes(rect, label="%d"%i) for i in range(4)]
16+
ax = [fig1.add_axes(rect, label="%d" % i) for i in range(4)]
1717

1818

1919
horiz = [Size.AxesX(ax[0]), Size.Fixed(.5), Size.AxesX(ax[1])]
@@ -40,5 +40,4 @@
4040
plt.setp(ax1.get_xticklabels()+ax1.get_yticklabels(),
4141
visible=False)
4242

43-
plt.draw()
4443
plt.show()

‎examples/axes_grid1/simple_colorbar.py

Copy file name to clipboardExpand all lines: examples/axes_grid1/simple_colorbar.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99
import numpy as np
1010

1111
ax = plt.subplot(111)
12-
im = ax.imshow(np.arange(100).reshape((10,10)))
12+
im = ax.imshow(np.arange(100).reshape((10, 10)))
1313

1414
# create an axes on the right side of ax. The width of cax will be 5%
1515
# of ax and the padding between cax and ax will be fixed at 0.05 inch.
1616
divider = make_axes_locatable(ax)
1717
cax = divider.append_axes("right", size="5%", pad=0.05)
1818

1919
plt.colorbar(im, cax=cax)
20-

‎examples/axes_grid1/simple_rgb.py

Copy file name to clipboardExpand all lines: examples/axes_grid1/simple_rgb.py
+8-8Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,25 @@
88

99
from mpl_toolkits.axes_grid1.axes_rgb import RGBAxes
1010

11+
1112
def get_demo_image():
1213
import numpy as np
1314
from matplotlib.cbook import get_sample_data
1415
f = get_sample_data("axes_grid/bivariate_normal.npy", asfileobj=False)
1516
z = np.load(f)
1617
# z is a numpy array of 15x15
17-
return z, (-3,4,-4,3)
18+
return z, (-3, 4, -4, 3)
19+
1820

1921
def get_rgb():
2022
Z, extent = get_demo_image()
2123

22-
Z[Z<0] = 0.
23-
Z = Z/Z.max()
24+
Z[Z < 0] = 0.
25+
Z = Z / Z.max()
2426

25-
R = Z[:13,:13]
26-
G = Z[2:,2:]
27-
B = Z[:13,2:]
27+
R = Z[:13, :13]
28+
G = Z[2:, 2:]
29+
B = Z[:13, 2:]
2830

2931
return R, G, B
3032

@@ -39,6 +41,4 @@ def get_rgb():
3941
ax.RGB.set_xlim(0., 9.5)
4042
ax.RGB.set_ylim(0.9, 10.6)
4143

42-
43-
plt.draw()
4444
plt.show()

‎examples/pylab_examples/ginput_manual_clabel_sgskip.py

Copy file name to clipboardExpand all lines: examples/pylab_examples/ginput_manual_clabel_sgskip.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def tellme(s):
6161
for p in ph:
6262
p.remove()
6363

64+
6465
##################################################
6566
# Now contour according to distance from triangle
6667
# corners - just an example

‎examples/user_interfaces/embedding_in_qt5_sgskip.py

Copy file name to clipboardExpand all lines: examples/user_interfaces/embedding_in_qt5_sgskip.py
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414
may be distributed without limitation.
1515
"""
1616

17-
18-
1917
from __future__ import unicode_literals
2018
import sys
2119
import os

‎examples/userdemo/anchored_box01.py

Copy file name to clipboardExpand all lines: examples/userdemo/anchored_box01.py
+3-5Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@
77
import matplotlib.pyplot as plt
88
from matplotlib.offsetbox import AnchoredText
99

10-
fig=plt.figure(1, figsize=(3,3))
11-
ax = plt.subplot(111)
10+
11+
fig, ax = plt.subplots(figsize=(3, 3))
1212

1313
at = AnchoredText("Figure 1a",
14-
prop=dict(size=15), frameon=True,
15-
loc=2,
16-
)
14+
prop=dict(size=15), frameon=True, loc=2)
1715
at.patch.set_boxstyle("round,pad=0.,rounding_size=0.2")
1816
ax.add_artist(at)
1917

‎examples/userdemo/anchored_box02.py

Copy file name to clipboardExpand all lines: examples/userdemo/anchored_box02.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,8 @@
88
import matplotlib.pyplot as plt
99
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredDrawingArea
1010

11-
fig=plt.figure(1, figsize=(3,3))
12-
ax = plt.subplot(111)
1311

12+
fig, ax = plt.subplots(figsize=(3, 3))
1413

1514
ada = AnchoredDrawingArea(40, 20, 0, 0,
1615
loc=1, pad=0., frameon=False)

‎examples/userdemo/anchored_box03.py

Copy file name to clipboardExpand all lines: examples/userdemo/anchored_box03.py
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
import matplotlib.pyplot as plt
99
from mpl_toolkits.axes_grid1.anchored_artists import AnchoredAuxTransformBox
1010

11-
fig=plt.figure(1, figsize=(3,3))
12-
ax = plt.subplot(111)
11+
12+
fig, ax = plt.subplots(figsize=(3, 3))
1313

1414
box = AnchoredAuxTransformBox(ax.transData, loc=2)
15-
el = Ellipse((0,0), width=0.1, height=0.4, angle=30) # in data coordinates!
15+
el = Ellipse((0, 0), width=0.1, height=0.4, angle=30) # in data coordinates!
1616
box.drawing_area.add_artist(el)
1717

1818
ax.add_artist(box)

‎examples/userdemo/anchored_box04.py

Copy file name to clipboardExpand all lines: examples/userdemo/anchored_box04.py
+6-7Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,22 @@
66
"""
77
from matplotlib.patches import Ellipse
88
import matplotlib.pyplot as plt
9-
from matplotlib.offsetbox import AnchoredOffsetbox, TextArea, DrawingArea, HPacker
9+
from matplotlib.offsetbox import (AnchoredOffsetbox, DrawingArea, HPacker,
10+
TextArea)
1011

11-
fig=plt.figure(1, figsize=(3,3))
12-
ax = plt.subplot(111)
12+
13+
fig, ax = plt.subplots(figsize=(3, 3))
1314

1415
box1 = TextArea(" Test : ", textprops=dict(color="k"))
1516

1617
box2 = DrawingArea(60, 20, 0, 0)
1718
el1 = Ellipse((10, 10), width=16, height=5, angle=30, fc="r")
18-
el2 = Ellipse((30, 10), width=16, height=5, angle=170, fc="g")
19-
el3 = Ellipse((50, 10), width=16, height=5, angle=230, fc="b")
19+
el2 = Ellipse((30, 10), width=16, height=5, angle=170, fc="g")
20+
el3 = Ellipse((50, 10), width=16, height=5, angle=230, fc="b")
2021
box2.add_artist(el1)
2122
box2.add_artist(el2)
2223
box2.add_artist(el3)
2324

24-
2525
box = HPacker(children=[box1, box2],
2626
align="center",
2727
pad=0, sep=5)
@@ -34,7 +34,6 @@
3434
borderpad=0.,
3535
)
3636

37-
3837
ax.add_artist(anchored_box)
3938

4039
fig.subplots_adjust(top=0.8)

0 commit comments

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