Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TST: test_streamplot_2D faster #4221

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 5 additions & 17 deletions testsuite/MDAnalysisTests/visualization/test_streamlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def membrane_xtc(tmpdir_factory, univ):
z_delta += 0.02
return str(tmp_xtc)

def test_streamplot_2D(membrane_xtc, univ, tmpdir):
def test_streamplot_2D(membrane_xtc, univ):
# simple roundtrip test to ensure that
# a plot is generated by the 2D streamplot
# code
Expand All @@ -67,22 +67,10 @@ def test_streamplot_2D(membrane_xtc, univ, tmpdir):
ymax=univ.atoms.positions[...,1].max(),
maximum_delta_magnitude=2.0,
num_cores=1)
x = np.linspace(univ.atoms.positions[...,0].min(),
univ.atoms.positions[...,0].max(),
5)
y = np.linspace(univ.atoms.positions[...,1].min(),
univ.atoms.positions[...,1].max(),
5)
speed = np.sqrt(u1*u1 + v1*v1)
fig = plt.figure()
ax = fig.add_subplot(111, aspect='equal')
ax.streamplot(x, y, u1, v1, density=(10,10), color=speed, linewidth=3*speed/speed.max(),
cmap=plt.cm.viridis)
plot_outpath = os.path.join(str(tmpdir), 'testing_streamline.png')
fig.savefig(plot_outpath, dpi=300)

with open(plot_outpath, 'rb'):
pass
assert u1.shape == (5, 5)
assert v1.shape == (5, 5)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe spot checking values here might make sense--to be fair, we weren't doing that before either though

assert_allclose(avg, 0.965194167)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these single value checks? If so could we use pytest.approx instead (it is much faster last I checked)?

assert_allclose(std, 4.444808820e-06)


def test_streamplot_2D_zero_return(membrane_xtc, univ, tmpdir):
Expand Down