diff --git a/testsuite/MDAnalysisTests/visualization/test_streamlines.py b/testsuite/MDAnalysisTests/visualization/test_streamlines.py index d9af0ed85e..e60179dcf1 100644 --- a/testsuite/MDAnalysisTests/visualization/test_streamlines.py +++ b/testsuite/MDAnalysisTests/visualization/test_streamlines.py @@ -51,10 +51,9 @@ def membrane_xtc(tmpdir_factory, univ): z_delta += 0.02 return str(tmp_xtc) -def test_streamplot_2D(membrane_xtc, univ, tmpdir): - # simple roundtrip test to ensure that - # a plot is generated by the 2D streamplot - # code +def test_streamplot_2D(membrane_xtc, univ): + # regression test the data structures + # generated by the 2D streamplot code u1, v1, avg, std = streamlines.generate_streamlines(topology_file_path=Martini_membrane_gro, trajectory_file_path=membrane_xtc, grid_spacing=20, @@ -67,22 +66,18 @@ 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_allclose(u1, np.array([[0.79999924, 0.79999924, 0.80000687, 0.79999542, 0.79998779], + [0.80000019, 0.79999542, 0.79999924, 0.79999542, 0.80001068], + [0.8000021, 0.79999924, 0.80001068, 0.80000305, 0.79999542], + [0.80000019, 0.79999542, 0.80001068, 0.80000305, 0.80000305], + [0.79999828, 0.80000305, 0.80000305, 0.80000305, 0.79999542]])) + assert_allclose(v1, np.array([[0.53999901, 0.53999996, 0.53999996, 0.53999996, 0.54000092], + [0.5399971, 0.54000092, 0.54000092, 0.54000092, 0.5399971 ], + [0.54000473, 0.54000473, 0.54000092, 0.5399971, 0.54000473], + [0.54000092, 0.53999329, 0.53999329, 0.53999329, 0.54000092], + [0.54000092, 0.53999329, 0.53999329, 0.54000092, 0.53999329]])) + assert avg == pytest.approx(0.965194167) + assert std == pytest.approx(4.444808820e-06) def test_streamplot_2D_zero_return(membrane_xtc, univ, tmpdir):