Skip to content

Commit a531bb9

Browse files
committed
more test/ pylint
1 parent 980775e commit a531bb9

11 files changed

+61
-48
lines changed

Diff for: .pylintrc

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ disable=
77
invalid-name,
88
locally-disabled,
99
missing-docstring,
10+
no-member,
1011
too-few-public-methods,
1112
too-many-branches,
1213
too-many-statements,

Diff for: test/test_barchart.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def plot():
2323
w = 0.25
2424

2525
ax.bar(x-w, y1, w, color='b', align='center')
26-
ax.bar(x, y2, w, color='g', align='center')
26+
ax.bar(x, y2, w, color='g', align='center')
2727
ax.bar(x+w, y3, w, color='r', align='center')
2828

2929
return fig

Diff for: test/test_barchart_legend.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def plot():
2828
w = 0.25
2929

3030
ax.bar(x-w, y1, w, color='b', align='center', label='Data 1')
31-
ax.bar(x, y2, w, color='g', align='center', label='Data 2')
31+
ax.bar(x, y2, w, color='g', align='center', label='Data 2')
3232
ax.bar(x+w, y3, w, color='r', align='center', label='Data 3')
3333
ax.legend()
3434

Diff for: test/test_fancybox.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
bb = mtransforms.Bbox([[0.3, 0.4], [0.7, 0.6]])
1313

1414

15-
def draw_bbox(ax, bb):
15+
def draw_bbox(ax, bb_obj):
1616
# boxstyle=square with pad=0, i.e. bbox itself.
1717
p_bbox = FancyBboxPatch(
18-
(bb.xmin, bb.ymin),
19-
abs(bb.width), abs(bb.height),
18+
(bb_obj.xmin, bb_obj.ymin),
19+
abs(bb_obj.width), abs(bb_obj.height),
2020
boxstyle='square,pad=0.',
2121
ec='k', fc='none', zorder=10.,
2222
)

Diff for: test/test_heat.py

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def plot():
99
import numpy as np
1010

1111
fig = plt.figure()
12+
# pylint: disable=invalid-slice-index
1213
x, y = np.ogrid[-10:10:100j, -10:10:100j]
1314
extent = (x.min(), x.max(), y.min(), y.max())
1415
cmap = matplotlib.cm.get_cmap('gray')

Diff for: test/test_legend_best_location.py

+10-5
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ def plot():
3030

3131
# Legend best location is "center left"
3232
l, = axes[4].plot(t[30:], 2 * np.cos(10 * t[30:]), linewidth=0.5)
33-
l2, l3 = axes[4].plot(t, -1.5 * np.ones_like(t), t, 1.5 * np.ones_like(t))
33+
axes[4].plot(t, -1.5 * np.ones_like(t), t, 1.5 * np.ones_like(t))
3434
axes[4].legend((l,), ('CL',), loc=0)
3535

3636
# Legend best location is "center right"
3737
l, = axes[5].plot(t[:30], 2 * np.cos(10 * t[:30]), linewidth=0.5)
38-
l2, l3 = axes[5].plot(t, -1.5 * np.ones_like(t), t, 1.5 * np.ones_like(t))
38+
axes[5].plot(t, -1.5 * np.ones_like(t), t, 1.5 * np.ones_like(t))
3939
axes[5].legend((l,), ('CR',), loc=0)
4040

4141
# Legend best location is "lower center"
@@ -47,9 +47,14 @@ def plot():
4747
axes[7].legend((l,), ('UC',), loc=0)
4848

4949
# Legend best location is "center"
50-
l, l1 = axes[8].plot(t[:10], 2 * np.cos(10 * t[:10]), t[-10:],
51-
2 * np.cos(10 * t[-10:]), linewidth=0.5)
52-
l2, l3 = axes[8].plot(t, -2 * np.ones_like(t), t, 2 * np.ones_like(t))
50+
l, = axes[8].plot(
51+
t[:10],
52+
2 * np.cos(10 * t[:10]),
53+
t[-10:],
54+
2 * np.cos(10 * t[-10:]),
55+
linewidth=0.5
56+
)
57+
axes[8].plot(t, -2 * np.ones_like(t), t, 2 * np.ones_like(t))
5358
axes[8].legend((l,), ('C',), loc=0)
5459

5560
return fig

Diff for: test/test_legends2.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ def plot():
77
from matplotlib import pyplot as plt
88
import numpy as np
99

10-
fig, ax = plt.subplots(3, 3, sharex='col', sharey='row')
10+
fig, ax = plt.subplots(3, 3, sharex='col', sharey='row')
1111
axes = [ax[i][j] for i in range(len(ax)) for j in range(len(ax[i]))]
1212
for k, loc in enumerate(range(2, 11)):
1313
t1 = np.arange(0.0, 2.0, 0.1)
@@ -19,10 +19,10 @@ def plot():
1919
l1, = axes[k].plot(
2020
t2, np.exp(-t2), linewidth=0.5
2121
)
22-
l2, l3 = axes[k].plot(
22+
axes[k].plot(
2323
t2, np.sin(2*np.pi*t2), '--go', t1, np.log(1+t1), '.'
2424
)
25-
l4, = axes[k].plot(
25+
axes[k].plot(
2626
t2, np.exp(-t2)*np.sin(2*np.pi*t2), 'rs-.'
2727
)
2828

Diff for: test/test_logplot.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ def plot():
99
a = [pow(10, i) for i in range(10)]
1010
fig = plt.figure()
1111
ax = fig.add_subplot(1, 1, 1)
12-
line, = ax.semilogy(a, color='blue', lw=0.25)
12+
ax.semilogy(a, color='blue', lw=0.25)
1313

1414
plt.grid(b=True, which='major', color='g', linestyle='-', linewidth=0.25)
1515
plt.grid(b=True, which='minor', color='r', linestyle='--', linewidth=0.5)

Diff for: test/test_noise.py

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# -*- coding: utf-8 -*-
22
#
3+
from __future__ import print_function
4+
35
import helpers
46

5-
from numpy.random import randn
6-
from matplotlib import pyplot as plt
77
import numpy as np
8+
import matplotlib.pyplot as plt
89
import pytest
910

1011

@@ -14,7 +15,7 @@ def plot1():
1415
ax = fig.add_subplot(111)
1516

1617
np.random.seed(123)
17-
data = np.clip(randn(250, 250), -1, 1)
18+
data = np.clip(np.random.randn(250, 250), -1, 1)
1819

1920
cax = ax.imshow(data, interpolation='nearest')
2021
ax.set_title('Gaussian noise with vertical colorbar')
@@ -59,5 +60,5 @@ def test(plot, reference_phash):
5960
if __name__ == '__main__':
6061
# plot1()
6162
# plt.show()
62-
phash, _, _, _, _, _, _ = helpers.compute_phash(plot2())
63-
print(phash)
63+
ph, _, _, _, _, _, _ = helpers.compute_phash(plot2())
64+
print(ph)

Diff for: test/test_patches.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def plot():
4949
Wedge((0.8, 0.3), .2, 45, 90, width=0.10), # Ring sector
5050
]
5151

52-
for i in range(N):
52+
for _ in range(N):
5353
polygon = Polygon(np.random.rand(N, 2), True)
5454
patches.append(polygon)
5555

Diff for: test/test_rotated_labels.py

+33-28
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
# -*- coding: utf-8 -*-
22
#
3+
import os
4+
import tempfile
5+
36
import matplotlib2tikz
47

58
import pytest
6-
import tempfile
7-
import os
89
from matplotlib import pyplot as plt
910

1011

@@ -21,26 +22,28 @@ def __plot():
2122

2223

2324
@pytest.mark.parametrize(
24-
"x_alignment, y_alignment, x_tick_label_width,"
25-
"y_tick_label_width, rotation", [
26-
(None, None, "1rem", "3rem", 90),
27-
(None, "center", "1rem", "3rem", 90),
28-
("center", None, "1rem", "3rem", 90),
29-
("center", "center", None, "3rem", 90),
30-
("left", "left", None, "3rem", 90),
31-
("right", "right", None, "3rem", 90),
32-
("center", "center", "1rem", None, 90),
33-
("left", "left", "2rem", None, 90),
34-
("right", "right", "3rem", None, 90),
35-
("center", "center", "1rem", "3rem", 90),
36-
("left", "left", "2rem", "3rem", 90),
37-
("right", "right", "3rem", "3rem", 90),
38-
("left", "right", "2rem", "3rem", 90),
39-
("right", "left", "3rem", "3rem", 90),
25+
'x_alignment, y_alignment, x_tick_label_width,'
26+
'y_tick_label_width, rotation', [
27+
(None, None, '1rem', '3rem', 90),
28+
(None, 'center', '1rem', '3rem', 90),
29+
('center', None, '1rem', '3rem', 90),
30+
('center', 'center', None, '3rem', 90),
31+
('left', 'left', None, '3rem', 90),
32+
('right', 'right', None, '3rem', 90),
33+
('center', 'center', '1rem', None, 90),
34+
('left', 'left', '2rem', None, 90),
35+
('right', 'right', '3rem', None, 90),
36+
('center', 'center', '1rem', '3rem', 90),
37+
('left', 'left', '2rem', '3rem', 90),
38+
('right', 'right', '3rem', '3rem', 90),
39+
('left', 'right', '2rem', '3rem', 90),
40+
('right', 'left', '3rem', '3rem', 90),
4041
])
41-
def test_rotated_labels_parameters(x_alignment, y_alignment,
42-
x_tick_label_width, y_tick_label_width,
43-
rotation):
42+
def test_rotated_labels_parameters(
43+
x_alignment, y_alignment,
44+
x_tick_label_width, y_tick_label_width,
45+
rotation
46+
):
4447
fig, _ = __plot()
4548

4649
if x_alignment:
@@ -73,14 +76,16 @@ def test_rotated_labels_parameters(x_alignment, y_alignment,
7376
return
7477

7578

76-
@pytest.mark.parametrize("x_tick_label_width, y_tick_label_width", [
77-
(None, None),
78-
("1rem", None),
79-
(None, "3rem"),
80-
("2rem", "3rem"),
79+
@pytest.mark.parametrize('x_tick_label_width, y_tick_label_width', [
80+
(None, None),
81+
('1rem', None),
82+
(None, '3rem'),
83+
('2rem', '3rem'),
8184
])
82-
def test_rotated_labels_parameters_different_values(x_tick_label_width,
83-
y_tick_label_width):
85+
def test_rotated_labels_parameters_different_values(
86+
x_tick_label_width,
87+
y_tick_label_width
88+
):
8489
fig, ax = __plot()
8590

8691
plt.xticks(ha='left', rotation=90)

0 commit comments

Comments
 (0)