6
6
import io
7
7
8
8
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
11
10
import pytest
12
11
13
12
import matplotlib .pyplot as plt
@@ -87,7 +86,7 @@ def test__EventCollection__get_orientation():
87
86
orientation
88
87
'''
89
88
_ , coll , props = generate_EventCollection_plot ()
90
- assert_equal ( props ['orientation' ], coll .get_orientation () )
89
+ assert props ['orientation' ] == coll .get_orientation ()
91
90
92
91
93
92
def test__EventCollection__is_horizontal ():
@@ -96,31 +95,31 @@ def test__EventCollection__is_horizontal():
96
95
orientation
97
96
'''
98
97
_ , coll , _ = generate_EventCollection_plot ()
99
- assert_equal ( True , coll .is_horizontal () )
98
+ assert coll .is_horizontal ()
100
99
101
100
102
101
def test__EventCollection__get_linelength ():
103
102
'''
104
103
check to make sure the default linelength matches the input linelength
105
104
'''
106
105
_ , coll , props = generate_EventCollection_plot ()
107
- assert_equal ( props ['linelength' ], coll .get_linelength () )
106
+ assert props ['linelength' ] == coll .get_linelength ()
108
107
109
108
110
109
def test__EventCollection__get_lineoffset ():
111
110
'''
112
111
check to make sure the default lineoffset matches the input lineoffset
113
112
'''
114
113
_ , coll , props = generate_EventCollection_plot ()
115
- assert_equal ( props ['lineoffset' ], coll .get_lineoffset () )
114
+ assert props ['lineoffset' ] == coll .get_lineoffset ()
116
115
117
116
118
117
def test__EventCollection__get_linestyle ():
119
118
'''
120
119
check to make sure the default linestyle matches the input linestyle
121
120
'''
122
121
_ , coll , _ = generate_EventCollection_plot ()
123
- assert_equal ( coll .get_linestyle (), [(None , None )])
122
+ assert coll .get_linestyle () == [(None , None )]
124
123
125
124
126
125
def test__EventCollection__get_color ():
@@ -214,8 +213,8 @@ def test__EventCollection__switch_orientation():
214
213
splt , coll , props = generate_EventCollection_plot ()
215
214
new_orientation = 'vertical'
216
215
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 ()
219
218
new_positions = coll .get_positions ()
220
219
check_segments (coll ,
221
220
new_positions ,
@@ -237,8 +236,8 @@ def test__EventCollection__switch_orientation_2x():
237
236
coll .switch_orientation ()
238
237
coll .switch_orientation ()
239
238
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 ()
242
241
np .testing .assert_array_equal (props ['positions' ], new_positions )
243
242
check_segments (coll ,
244
243
new_positions ,
@@ -256,8 +255,8 @@ def test__EventCollection__set_orientation():
256
255
splt , coll , props = generate_EventCollection_plot ()
257
256
new_orientation = 'vertical'
258
257
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 ()
261
260
check_segments (coll ,
262
261
props ['positions' ],
263
262
props ['linelength' ],
@@ -276,7 +275,7 @@ def test__EventCollection__set_linelength():
276
275
splt , coll , props = generate_EventCollection_plot ()
277
276
new_linelength = 15
278
277
coll .set_linelength (new_linelength )
279
- assert_equal ( new_linelength , coll .get_linelength () )
278
+ assert new_linelength == coll .get_linelength ()
280
279
check_segments (coll ,
281
280
props ['positions' ],
282
281
new_linelength ,
@@ -294,7 +293,7 @@ def test__EventCollection__set_lineoffset():
294
293
splt , coll , props = generate_EventCollection_plot ()
295
294
new_lineoffset = - 5.
296
295
coll .set_lineoffset (new_lineoffset )
297
- assert_equal ( new_lineoffset , coll .get_lineoffset () )
296
+ assert new_lineoffset == coll .get_lineoffset ()
298
297
check_segments (coll ,
299
298
props ['positions' ],
300
299
props ['linelength' ],
@@ -312,7 +311,7 @@ def test__EventCollection__set_linestyle():
312
311
splt , coll , _ = generate_EventCollection_plot ()
313
312
new_linestyle = 'dashed'
314
313
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 ))]
316
315
splt .set_title ('EventCollection: set_linestyle' )
317
316
318
317
@@ -325,7 +324,7 @@ def test__EventCollection__set_linestyle_single_dash():
325
324
splt , coll , _ = generate_EventCollection_plot ()
326
325
new_linestyle = (0 , (6. , 6. ))
327
326
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 ))]
329
328
splt .set_title ('EventCollection: set_linestyle' )
330
329
331
330
@@ -337,7 +336,7 @@ def test__EventCollection__set_linewidth():
337
336
splt , coll , _ = generate_EventCollection_plot ()
338
337
new_linewidth = 5
339
338
coll .set_linewidth (new_linewidth )
340
- assert_equal ( coll .get_linewidth (), new_linewidth )
339
+ assert coll .get_linewidth () == new_linewidth
341
340
splt .set_title ('EventCollection: set_linewidth' )
342
341
343
342
@@ -376,10 +375,10 @@ def check_segments(coll, positions, linelength, lineoffset, orientation):
376
375
377
376
# test to make sure each segment is correct
378
377
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 ]
383
382
384
383
385
384
def check_allprop_array (values , target ):
@@ -408,15 +407,15 @@ def test_add_collection():
408
407
ax .add_collection (coll )
409
408
bounds = ax .dataLim .bounds
410
409
coll = ax .scatter ([], [])
411
- assert_equal ( ax .dataLim .bounds , bounds )
410
+ assert ax .dataLim .bounds == bounds
412
411
413
412
414
413
def test_quiver_limits ():
415
414
ax = plt .axes ()
416
415
x , y = np .arange (8 ), np .arange (10 )
417
416
u = v = np .linspace (0 , 10 , 80 ).reshape (10 , 8 )
418
417
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. )
420
419
421
420
plt .figure ()
422
421
ax = plt .axes ()
@@ -425,7 +424,7 @@ def test_quiver_limits():
425
424
y , x = np .meshgrid (y , x )
426
425
trans = mtransforms .Affine2D ().translate (25 , 32 ) + ax .transData
427
426
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 )
429
428
430
429
431
430
def test_barb_limits ():
@@ -615,28 +614,28 @@ def test_lslw_bcast():
615
614
col .set_linestyles (['-' , '-' ])
616
615
col .set_linewidths ([1 , 2 , 3 ])
617
616
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
620
619
621
620
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 ( )
624
623
625
624
626
625
@pytest .mark .style ('default' )
627
626
def test_capstyle ():
628
627
col = mcollections .PathCollection ([], capstyle = 'round' )
629
- assert_equal ( col .get_capstyle (), 'round' )
628
+ assert col .get_capstyle () == 'round'
630
629
col .set_capstyle ('butt' )
631
- assert_equal ( col .get_capstyle (), 'butt' )
630
+ assert col .get_capstyle () == 'butt'
632
631
633
632
634
633
@pytest .mark .style ('default' )
635
634
def test_joinstyle ():
636
635
col = mcollections .PathCollection ([], joinstyle = 'round' )
637
- assert_equal ( col .get_joinstyle (), 'round' )
636
+ assert col .get_joinstyle () == 'round'
638
637
col .set_joinstyle ('miter' )
639
- assert_equal ( col .get_joinstyle (), 'miter' )
638
+ assert col .get_joinstyle () == 'miter'
640
639
641
640
642
641
@image_comparison (baseline_images = ['cap_and_joinstyle' ],
0 commit comments