9
9
import numpy as np
10
10
11
11
12
+ @pytest .fixture
13
+ def baseline_images (request , extension ):
14
+ # strip the leading test_, and the file extension from the parameters
15
+ name = request .node .name
16
+ if name .startswith ('test_' ):
17
+ name = name [5 :]
18
+ name = name .replace ('[{}-' .format (extension ), '[' )
19
+ name = name .replace ('[]' , '' )
20
+ return [name ]
21
+
22
+
12
23
@image_comparison (baseline_images = ['bar3d' ], remove_text = True )
13
24
def test_bar3d ():
14
25
fig = plt .figure ()
@@ -21,12 +32,13 @@ def test_bar3d():
21
32
ax .bar (xs , ys , zs = z , zdir = 'y' , align = 'edge' , color = cs , alpha = 0.8 )
22
33
23
34
35
+ @pytest .mark .parametrize ('azim, elev' , [(- 60 , 30 ), (- 120 , 30 ), (120 , - 30 )])
24
36
@image_comparison (
25
- baseline_images = [ 'bar3d_shaded' ] ,
37
+ baseline_images = None ,
26
38
remove_text = True ,
27
39
extensions = ['png' ]
28
40
)
29
- def test_bar3d_shaded ():
41
+ def test_bar3d_shaded (baseline_images , azim , elev ):
30
42
fig = plt .figure ()
31
43
ax = fig .add_subplot (111 , projection = '3d' )
32
44
x = np .arange (4 )
@@ -35,6 +47,7 @@ def test_bar3d_shaded():
35
47
x2d , y2d = x2d .ravel (), y2d .ravel ()
36
48
z = x2d + y2d
37
49
ax .bar3d (x2d , y2d , x2d * 0 , 1 , 1 , z , shade = True )
50
+ ax .view_init (azim = azim , elev = elev )
38
51
fig .canvas .draw ()
39
52
40
53
0 commit comments