Skip to content

Commit be12168

Browse files
authored
Merge pull request matplotlib#10539 from QuLogic/no-assert_equal
TST: Replace assert_equal with plain asserts.
2 parents 180639b + e4998b1 commit be12168

File tree

2 files changed

+36
-39
lines changed

2 files changed

+36
-39
lines changed

lib/matplotlib/tests/test_backend_qt5.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
from matplotlib import pyplot as plt
77
from matplotlib._pylab_helpers import Gcf
88

9-
from numpy.testing import assert_equal
10-
119
import pytest
1210
try:
1311
# mock in python 3.3+
@@ -135,8 +133,8 @@ def test_dpi_ratio_change():
135133
# The actual widget size and figure physical size don't change
136134
assert size.width() == 600
137135
assert size.height() == 240
138-
assert_equal(qt_canvas.get_width_height(), (600, 240))
139-
assert_equal(fig.get_size_inches(), (5, 2))
136+
assert qt_canvas.get_width_height() == (600, 240)
137+
assert (fig.get_size_inches() == (5, 2)).all()
140138

141139
p.return_value = 2
142140

@@ -158,8 +156,8 @@ def test_dpi_ratio_change():
158156
# The actual widget size and figure physical size don't change
159157
assert size.width() == 600
160158
assert size.height() == 240
161-
assert_equal(qt_canvas.get_width_height(), (600, 240))
162-
assert_equal(fig.get_size_inches(), (5, 2))
159+
assert qt_canvas.get_width_height() == (600, 240)
160+
assert (fig.get_size_inches() == (5, 2)).all()
163161

164162

165163
@pytest.mark.backend('Qt5Agg')

lib/matplotlib/tests/test_collections.py

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
import io
77

88
import numpy as np
9-
from numpy.testing import (
10-
assert_array_equal, assert_array_almost_equal, assert_equal)
9+
from numpy.testing import assert_array_equal, assert_array_almost_equal
1110
import pytest
1211

1312
import matplotlib.pyplot as plt
@@ -87,7 +86,7 @@ def test__EventCollection__get_orientation():
8786
orientation
8887
'''
8988
_, coll, props = generate_EventCollection_plot()
90-
assert_equal(props['orientation'], coll.get_orientation())
89+
assert props['orientation'] == coll.get_orientation()
9190

9291

9392
def test__EventCollection__is_horizontal():
@@ -96,31 +95,31 @@ def test__EventCollection__is_horizontal():
9695
orientation
9796
'''
9897
_, coll, _ = generate_EventCollection_plot()
99-
assert_equal(True, coll.is_horizontal())
98+
assert coll.is_horizontal()
10099

101100

102101
def test__EventCollection__get_linelength():
103102
'''
104103
check to make sure the default linelength matches the input linelength
105104
'''
106105
_, coll, props = generate_EventCollection_plot()
107-
assert_equal(props['linelength'], coll.get_linelength())
106+
assert props['linelength'] == coll.get_linelength()
108107

109108

110109
def test__EventCollection__get_lineoffset():
111110
'''
112111
check to make sure the default lineoffset matches the input lineoffset
113112
'''
114113
_, coll, props = generate_EventCollection_plot()
115-
assert_equal(props['lineoffset'], coll.get_lineoffset())
114+
assert props['lineoffset'] == coll.get_lineoffset()
116115

117116

118117
def test__EventCollection__get_linestyle():
119118
'''
120119
check to make sure the default linestyle matches the input linestyle
121120
'''
122121
_, coll, _ = generate_EventCollection_plot()
123-
assert_equal(coll.get_linestyle(), [(None, None)])
122+
assert coll.get_linestyle() == [(None, None)]
124123

125124

126125
def test__EventCollection__get_color():
@@ -214,8 +213,8 @@ def test__EventCollection__switch_orientation():
214213
splt, coll, props = generate_EventCollection_plot()
215214
new_orientation = 'vertical'
216215
coll.switch_orientation()
217-
assert_equal(new_orientation, coll.get_orientation())
218-
assert_equal(False, coll.is_horizontal())
216+
assert new_orientation == coll.get_orientation()
217+
assert not coll.is_horizontal()
219218
new_positions = coll.get_positions()
220219
check_segments(coll,
221220
new_positions,
@@ -237,8 +236,8 @@ def test__EventCollection__switch_orientation_2x():
237236
coll.switch_orientation()
238237
coll.switch_orientation()
239238
new_positions = coll.get_positions()
240-
assert_equal(props['orientation'], coll.get_orientation())
241-
assert_equal(True, coll.is_horizontal())
239+
assert props['orientation'] == coll.get_orientation()
240+
assert coll.is_horizontal()
242241
np.testing.assert_array_equal(props['positions'], new_positions)
243242
check_segments(coll,
244243
new_positions,
@@ -256,8 +255,8 @@ def test__EventCollection__set_orientation():
256255
splt, coll, props = generate_EventCollection_plot()
257256
new_orientation = 'vertical'
258257
coll.set_orientation(new_orientation)
259-
assert_equal(new_orientation, coll.get_orientation())
260-
assert_equal(False, coll.is_horizontal())
258+
assert new_orientation == coll.get_orientation()
259+
assert not coll.is_horizontal()
261260
check_segments(coll,
262261
props['positions'],
263262
props['linelength'],
@@ -276,7 +275,7 @@ def test__EventCollection__set_linelength():
276275
splt, coll, props = generate_EventCollection_plot()
277276
new_linelength = 15
278277
coll.set_linelength(new_linelength)
279-
assert_equal(new_linelength, coll.get_linelength())
278+
assert new_linelength == coll.get_linelength()
280279
check_segments(coll,
281280
props['positions'],
282281
new_linelength,
@@ -294,7 +293,7 @@ def test__EventCollection__set_lineoffset():
294293
splt, coll, props = generate_EventCollection_plot()
295294
new_lineoffset = -5.
296295
coll.set_lineoffset(new_lineoffset)
297-
assert_equal(new_lineoffset, coll.get_lineoffset())
296+
assert new_lineoffset == coll.get_lineoffset()
298297
check_segments(coll,
299298
props['positions'],
300299
props['linelength'],
@@ -312,7 +311,7 @@ def test__EventCollection__set_linestyle():
312311
splt, coll, _ = generate_EventCollection_plot()
313312
new_linestyle = 'dashed'
314313
coll.set_linestyle(new_linestyle)
315-
assert_equal(coll.get_linestyle(), [(0, (6.0, 6.0))])
314+
assert coll.get_linestyle() == [(0, (6.0, 6.0))]
316315
splt.set_title('EventCollection: set_linestyle')
317316

318317

@@ -325,7 +324,7 @@ def test__EventCollection__set_linestyle_single_dash():
325324
splt, coll, _ = generate_EventCollection_plot()
326325
new_linestyle = (0, (6., 6.))
327326
coll.set_linestyle(new_linestyle)
328-
assert_equal(coll.get_linestyle(), [(0, (6.0, 6.0))])
327+
assert coll.get_linestyle() == [(0, (6.0, 6.0))]
329328
splt.set_title('EventCollection: set_linestyle')
330329

331330

@@ -337,7 +336,7 @@ def test__EventCollection__set_linewidth():
337336
splt, coll, _ = generate_EventCollection_plot()
338337
new_linewidth = 5
339338
coll.set_linewidth(new_linewidth)
340-
assert_equal(coll.get_linewidth(), new_linewidth)
339+
assert coll.get_linewidth() == new_linewidth
341340
splt.set_title('EventCollection: set_linewidth')
342341

343342

@@ -376,10 +375,10 @@ def check_segments(coll, positions, linelength, lineoffset, orientation):
376375

377376
# test to make sure each segment is correct
378377
for i, segment in enumerate(segments):
379-
assert_equal(segment[0, pos1], lineoffset + linelength / 2.)
380-
assert_equal(segment[1, pos1], lineoffset - linelength / 2.)
381-
assert_equal(segment[0, pos2], positions[i])
382-
assert_equal(segment[1, pos2], positions[i])
378+
assert segment[0, pos1] == lineoffset + linelength / 2
379+
assert segment[1, pos1] == lineoffset - linelength / 2
380+
assert segment[0, pos2] == positions[i]
381+
assert segment[1, pos2] == positions[i]
383382

384383

385384
def check_allprop_array(values, target):
@@ -408,15 +407,15 @@ def test_add_collection():
408407
ax.add_collection(coll)
409408
bounds = ax.dataLim.bounds
410409
coll = ax.scatter([], [])
411-
assert_equal(ax.dataLim.bounds, bounds)
410+
assert ax.dataLim.bounds == bounds
412411

413412

414413
def test_quiver_limits():
415414
ax = plt.axes()
416415
x, y = np.arange(8), np.arange(10)
417416
u = v = np.linspace(0, 10, 80).reshape(10, 8)
418417
q = plt.quiver(x, y, u, v)
419-
assert_equal(q.get_datalim(ax.transData).bounds, (0., 0., 7., 9.))
418+
assert q.get_datalim(ax.transData).bounds == (0., 0., 7., 9.)
420419

421420
plt.figure()
422421
ax = plt.axes()
@@ -425,7 +424,7 @@ def test_quiver_limits():
425424
y, x = np.meshgrid(y, x)
426425
trans = mtransforms.Affine2D().translate(25, 32) + ax.transData
427426
plt.quiver(x, y, np.sin(x), np.cos(y), transform=trans)
428-
assert_equal(ax.dataLim.bounds, (20.0, 30.0, 15.0, 6.0))
427+
assert ax.dataLim.bounds == (20.0, 30.0, 15.0, 6.0)
429428

430429

431430
def test_barb_limits():
@@ -615,28 +614,28 @@ def test_lslw_bcast():
615614
col.set_linestyles(['-', '-'])
616615
col.set_linewidths([1, 2, 3])
617616

618-
assert_equal(col.get_linestyles(), [(None, None)] * 6)
619-
assert_equal(col.get_linewidths(), [1, 2, 3] * 2)
617+
assert col.get_linestyles() == [(None, None)] * 6
618+
assert col.get_linewidths() == [1, 2, 3] * 2
620619

621620
col.set_linestyles(['-', '-', '-'])
622-
assert_equal(col.get_linestyles(), [(None, None)] * 3)
623-
assert_equal(col.get_linewidths(), [1, 2, 3])
621+
assert col.get_linestyles() == [(None, None)] * 3
622+
assert (col.get_linewidths() == [1, 2, 3]).all()
624623

625624

626625
@pytest.mark.style('default')
627626
def test_capstyle():
628627
col = mcollections.PathCollection([], capstyle='round')
629-
assert_equal(col.get_capstyle(), 'round')
628+
assert col.get_capstyle() == 'round'
630629
col.set_capstyle('butt')
631-
assert_equal(col.get_capstyle(), 'butt')
630+
assert col.get_capstyle() == 'butt'
632631

633632

634633
@pytest.mark.style('default')
635634
def test_joinstyle():
636635
col = mcollections.PathCollection([], joinstyle='round')
637-
assert_equal(col.get_joinstyle(), 'round')
636+
assert col.get_joinstyle() == 'round'
638637
col.set_joinstyle('miter')
639-
assert_equal(col.get_joinstyle(), 'miter')
638+
assert col.get_joinstyle() == 'miter'
640639

641640

642641
@image_comparison(baseline_images=['cap_and_joinstyle'],

0 commit comments

Comments
 (0)