8000 Make streamplot test data rectangular. · matplotlib/matplotlib@51d035e · GitHub
[go: up one dir, main page]

Skip to content

Commit 51d035e

Browse files
committed
Make streamplot test data rectangular.
Wherein test images needed changing, the compatibility code for the original images has also been removed.
1 parent a0cea21 commit 51d035e

11 files changed

+8534
-7777
lines changed
Binary file not shown.
Loading

lib/matplotlib/tests/baseline_images/test_streamplot/streamplot_colormap.svg

Lines changed: 2267 additions & 2179 deletions
Loading
Binary file not shown.
Loading

lib/matplotlib/tests/baseline_images/test_streamplot/streamplot_linewidth.svg

Lines changed: 2819 additions & 2268 deletions
Loading
Binary file not shown.
Loading

lib/matplotlib/tests/baseline_images/test_streamplot/streamplot_masks_and_nans.svg

Lines changed: 3437 additions & 3301 deletions
Loading
Binary file not shown.

lib/matplotlib/tests/test_streamplot.py

Lines changed: 11 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import sys
2-
31
import numpy as np
42
from numpy.testing import assert_array_almost_equal
53
import pytest
@@ -8,19 +6,15 @@
86
import matplotlib.transforms as mtransforms
97

108

11-
on_win = (sys.platform == 'win32')
12-
on_mac = (sys.platform == 'darwin')
13-
14-
159
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]
1711
U = -1 - X**2 + Y
1812
V = 1 + X - Y**2
1913
return X, Y, U, V
2014

2115

2216
def swirl_velocity_field():
23-
x = np.linspace(-3., 3., 100)
17+
x = np.linspace(-3., 3., 200)
2418
y = np.linspace(-3., 3., 100)
2519
X, Y = np.meshgrid(x, y)
2620
a = 0.1
@@ -29,7 +23,8 @@ def swirl_velocity_field():
2923
return x, y, U, V
3024

3125

32-
@image_comparison(['streamplot_startpoints'], remove_text=True, style='mpl20')
26+
@image_comparison(['streamplot_startpoints'], remove_text=True, style='mpl20',
27+
tol=0.513)
3328
def test_startpoints():
3429
X, Y, U, V = velocity_field()
3530
start_x = np.linspace(X.min(), X.max(), 10)
@@ -39,12 +34,8 @@ def test_startpoints():
3934
plt.plot(start_x, start_y, 'ok')
4035

4136

42-
@image_comparison(['streamplot_colormap'],
43-
tol=.04, remove_text=True, style='mpl20')
37+
@image_comparison(['streamplot_colormap'], remove_text=True, style='mpl20')
4438
def test_colormap():
45-
# Remove this line when this test image is regenerated.
46-
plt.rcParams['pcolormesh.snap'] = False
47-
4839
X, Y, U, V = velocity_field()
4940
plt.streamplot(X, Y, U, V, color=U, density=0.6, linewidth=2,
5041
cmap=plt.cm.autumn)
@@ -56,34 +47,25 @@ def test_linewidth():
5647
X, Y, U, V = velocity_field()
5748
speed = np.hypot(U, V)
5849
lw = 5 * speed / speed.max()
59-
# Compatibility for old test image
60-
df = 25 / 30
6150
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)
6652

6753

6854
@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')
7056
def test_masks_and_nans():
7157
X, Y, U, V = velocity_field()
7258
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
7561
U = np.ma.array(U, mask=mask)
76-
# Compatibility for old test image
7762
ax = plt.figure().subplots()
78-
ax.set(xlim=(-3.0, 2.9999999999999947),
79-
ylim=(-3.0000000000000004, 2.9999999999999947))
8063
with np.errstate(invalid='ignore'):
8164
ax.streamplot(X, Y, U, V, color=U, cmap=plt.cm.Blues)
8265

8366

8467
@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)
8769
def test_maxlength():
8870
x, y, U, V = swirl_velocity_field()
8971
ax = plt.figure().subplots()
@@ -95,7 +77,7 @@ def test_maxlength():
9577

9678

9779
@image_comparison(['streamplot_direction.png'],
98-
remove_text=True, style='mpl20')
80+
remove_text=True, style='mpl20', tol=0.056)
9981
def test_direction():
10082
x, y, U, V = swirl_velocity_field()
10183
plt.streamplot(x, y, U, V, integration_direction='backward',

0 commit comments

Comments
 (0)
0