|
21 | 21 | # J. Comput. Chem. 32 (2011), 2319--2327, doi:10.1002/jcc.21787
|
22 | 22 | #
|
23 | 23 | import numpy as np
|
| 24 | +from numpy.testing import assert_allclose |
24 | 25 | import MDAnalysis
|
25 | 26 | from MDAnalysis.visualization import (streamlines,
|
26 | 27 | streamlines_3D)
|
@@ -83,6 +84,29 @@ def test_streamplot_2D(membrane_xtc, univ, tmpdir):
|
83 | 84 | with open(plot_outpath, 'rb'):
|
84 | 85 | pass
|
85 | 86 |
|
| 87 | + |
| 88 | +def test_streamplot_2D_zero_return(membrane_xtc, univ, tmpdir): |
| 89 | + # simple roundtrip test to ensure that |
| 90 | + # zeroed arrays are returned by the 2D streamplot |
| 91 | + # code when called with an empty selection |
| 92 | + u1, v1, avg, std = streamlines.generate_streamlines(topology_file_path=Martini_membrane_gro, |
| 93 | + trajectory_file_path=membrane_xtc, |
| 94 | + grid_spacing=20, |
| 95 | + MDA_selection='name POX', |
| 96 | + start_frame=1, |
| 97 | + end_frame=2, |
| 98 | + xmin=univ.atoms.positions[...,0].min(), |
| 99 | + xmax=univ.atoms.positions[...,0].max(), |
| 100 | + ymin=univ.atoms.positions[...,1].min(), |
| 101 | + ymax=univ.atoms.positions[...,1].max(), |
| 102 | + maximum_delta_magnitude=2.0, |
| 103 | + num_cores=1) |
| 104 | + assert_allclose(u1, np.zeros((5, 5))) |
| 105 | + assert_allclose(v1, np.zeros((5, 5))) |
| 106 | + assert avg == approx(0.0) |
| 107 | + assert std == approx(0.0) |
| 108 | + |
| 109 | + |
86 | 110 | def test_streamplot_3D(membrane_xtc, univ, tmpdir):
|
87 | 111 | # because mayavi is too heavy of a dependency
|
88 | 112 | # for a roundtrip plotting test, simply
|
|
0 commit comments