Skip to content

Commit 0423430

Browse files
committed
Merge pull request #6239 from jenshnielsen/cleanexampleswarnings
Clean warnings in examples
2 parents 5d0ca1d + d82de88 commit 0423430

File tree

6 files changed

+19
-16
lines changed

6 files changed

+19
-16
lines changed

examples/api/power_norm_demo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import numpy as np
66
from numpy.random import multivariate_normal
77

8-
data = np.vstack([multivariate_normal([10, 10], [[2, 2], [2, 2]], size=100000),
8+
data = np.vstack([multivariate_normal([10, 10], [[3, 2], [2, 3]], size=100000),
99
multivariate_normal([30, 20], [[2, 3], [1, 3]], size=1000)
1010
])
1111

examples/pylab_examples/centered_ticklabels.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@
4545
tick.tick2line.set_markersize(0)
4646
tick.label1.set_horizontalalignment('center')
4747

48-
imid = len(r)/2
48+
imid = len(r)//2
4949
ax.set_xlabel(str(r.date[imid].year))
5050
plt.show()

examples/pylab_examples/data_helper.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ def get_two_stock_data():
1717
file2 = cbook.get_sample_data('AAPL.dat.gz')
1818
M1 = fromstring(file1.read(), '<d')
1919

20-
M1 = resize(M1, (M1.shape[0]/2, 2))
20+
M1 = resize(M1, (M1.shape[0]//2, 2))
2121

2222
M2 = fromstring(file2.read(), '<d')
23-
M2 = resize(M2, (M2.shape[0]/2, 2))
23+
M2 = resize(M2, (M2.shape[0]//2, 2))
2424

2525
d1, p1 = M1[:, 0], M1[:, 1]
2626
d2, p2 = M2[:, 0], M2[:, 1]
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import print_function
22
import numpy
3-
from matplotlib.pyplot import figure, show
3+
import matplotlib.pyplot as plt
44

55

66
class IndexTracker(object):
@@ -10,7 +10,7 @@ def __init__(self, ax, X):
1010

1111
self.X = X
1212
rows, cols, self.slices = X.shape
13-
self.ind = self.slices/2
13+
self.ind = self.slices//2
1414

1515
self.im = ax.imshow(self.X[:, :, self.ind])
1616
self.update()
@@ -21,7 +21,6 @@ def onscroll(self, event):
2121
self.ind = numpy.clip(self.ind + 1, 0, self.slices - 1)
2222
else:
2323
self.ind = numpy.clip(self.ind - 1, 0, self.slices - 1)
24-
2524
self.update()
2625

2726
def update(self):
@@ -30,13 +29,12 @@ def update(self):
3029
self.im.axes.figure.canvas.draw()
3130

3231

33-
fig = figure()
34-
ax = fig.add_subplot(111)
32+
fig, ax = plt.subplots(1, 1)
3533

3634
X = numpy.random.rand(20, 20, 40)
3735

3836
tracker = IndexTracker(ax, X)
3937

4038

4139
fig.canvas.mpl_connect('scroll_event', tracker.onscroll)
42-
show()
40+
plt.show()

examples/pylab_examples/quiver_demo.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,13 @@
7575
# 6
7676
plt.figure()
7777
M = np.zeros(U.shape, dtype='bool')
78-
M[U.shape[0]/3:2*U.shape[0]/3,
79-
U.shape[1]/3:2*U.shape[1]/3] = True
78+
XMaskStart = U.shape[0]//3
79+
YMaskStart = U.shape[1]//3
80+
XMaskStop = 2*U.shape[0]//3
81+
YMaskStop = 2*U.shape[1]//3
82+
83+
M[XMaskStart:XMaskStop,
84+
YMaskStart:YMaskStop] = True
8085
U = ma.masked_array(U, mask=M)
8186
V = ma.masked_array(V, mask=M)
8287
Q = plt.quiver(U, V)

lib/mpl_toolkits/axisartist/grid_finder.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -255,14 +255,14 @@ def __init__(self,
255255

256256

257257
class MaxNLocator(mticker.MaxNLocator):
258-
def __init__(self, nbins = 10, steps = None,
259-
trim = True,
258+
def __init__(self, nbins=10, steps=None,
259+
trim=True,
260260
integer=False,
261261
symmetric=False,
262262
prune=None):
263-
263+
# trim argument has no effect. It has been left for API compatibility
264264
mticker.MaxNLocator.__init__(self, nbins, steps=steps,
265-
trim=trim, integer=integer,
265+
integer=integer,
266266
symmetric=symmetric, prune=prune)
267267
self.create_dummy_axis()
268268
self._factor = None

0 commit comments

Comments
 (0)