1
- import sys
2
-
3
1
import numpy as np
4
2
from numpy .testing import assert_array_almost_equal
5
3
import pytest
8
6
import matplotlib .transforms as mtransforms
9
7
10
8
11
- on_win = (sys .platform == 'win32' )
12
- on_mac = (sys .platform == 'darwin' )
13
-
14
-
15
9
def velocity_field ():
16
- Y , X = np .mgrid [- 3 :3 :100j , - 3 :3 :100j ]
10
+ Y , X = np .mgrid [- 3 :3 :100j , - 3 :3 :200j ]
17
11
U = - 1 - X ** 2 + Y
18
12
V = 1 + X - Y ** 2
19
13
return X , Y , U , V
20
14
21
15
22
16
def swirl_velocity_field ():
23
- x = np .linspace (- 3. , 3. , 100 )
17
+ x = np .linspace (- 3. , 3. , 200 )
24
18
y = np .linspace (- 3. , 3. , 100 )
25
19
X , Y = np .meshgrid (x , y )
26
20
a = 0.1
@@ -29,7 +23,8 @@ def swirl_velocity_field():
29
23
return x , y , U , V
30
24
31
25
32
- @image_comparison (['streamplot_startpoints' ], remove_text = True , style = 'mpl20' )
26
+ @image_comparison (['streamplot_startpoints' ], remove_text = True , style = 'mpl20' ,
27
+ tol = 0.513 )
33
28
def test_startpoints ():
34
29
X , Y , U , V = velocity_field ()
35
30
start_x = np .linspace (X .min (), X .max (), 10 )
@@ -39,12 +34,8 @@ def test_startpoints():
39
34
plt .plot (start_x , start_y , 'ok' )
40
35
41
36
42
- @image_comparison (['streamplot_colormap' ],
43
- tol = .04 , remove_text = True , style = 'mpl20' )
37
+ @image_comparison (['streamplot_colormap' ], remove_text = True , style = 'mpl20' )
44
38
def test_colormap ():
45
- # Remove this line when this test image is regenerated.
46
- plt .rcParams ['pcolormesh.snap' ] = False
47
-
48
39
X , Y , U , V = velocity_field ()
49
40
plt .streamplot (X , Y , U , V , color = U , density = 0.6 , linewidth = 2 ,
50
41
cmap = plt .cm .autumn )
@@ -56,34 +47,25 @@ def test_linewidth():
56
47
X , Y , U , V = velocity_field ()
57
48
speed = np .hypot (U , V )
58
49
lw = 5 * speed / speed .max ()
59
- # Compatibility for old test image
60
- df = 25 / 30
61
50
ax = plt .figure ().subplots ()
62
- ax .set (xlim = (- 3.0 , 2.9999999999999947 ),
63
- ylim = (- 3.0000000000000004 , 2.9999999999999947 ))
64
- ax .streamplot (X , Y , U , V , density = [0.5 * df , 1. * df ], color = 'k' ,
65
- linewidth = lw )
51
+ ax .streamplot (X , Y , U , V , density = [0.5 , 1 ], color = 'k' , linewidth = lw )
66
52
67
53
68
54
@image_comparison (['streamplot_masks_and_nans' ],
69
- remove_text = True , style = 'mpl20' , tol = 0.04 if on_win else 0 )
55
+ remove_text = True , style = 'mpl20' )
70
56
def test_masks_and_nans ():
71
57
X , Y , U , V = velocity_field ()
72
58
mask = np .zeros (U .shape , dtype = bool )
73
- mask [40 :60 , 40 : 60 ] = 1
74
- U [:20 , :20 ] = np .nan
59
+ mask [40 :60 , 80 : 120 ] = 1
60
+ U [:20 , :40 ] = np .nan
75
61
U = np .ma .array (U , mask = mask )
76
- # Compatibility for old test image
77
62
ax = plt .figure ().subplots ()
78
- ax .set (xlim = (- 3.0 , 2.9999999999999947 ),
79
- ylim = (- 3.0000000000000004 , 2.9999999999999947 ))
80
63
with np .errstate (invalid = 'ignore' ):
81
64
ax .streamplot (X , Y , U , V , color = U , cmap = plt .cm .Blues )
82
65
83
66
84
67
@image_comparison (['streamplot_maxlength.png' ],
85
- remove_text = True , style = 'mpl20' ,
86
- tol = 0.002 if on_mac else 0 )
68
+ remove_text = True , style = 'mpl20' , tol = 0.302 )
87
69
def test_maxlength ():
88
70
x , y , U , V = swirl_velocity_field ()
89
71
ax = plt .figure ().subplots ()
@@ -95,7 +77,7 @@ def test_maxlength():
95
77
96
78
97
79
@image_comparison (['streamplot_direction.png' ],
98
- remove_text = True , style = 'mpl20' )
80
+ remove_text = True , style = 'mpl20' , tol = 0.056 )
99
81
def test_direction ():
100
82
x , y , U , V = swirl_velocity_field ()
101
83
plt .streamplot (x , y , U , V , integration_direction = 'backward' ,
0 commit comments