MCPcopy Create free account
hub / github.com/cpmech/plotpy / test_stream_arrows_2

Function test_stream_arrows_2

tests/test_stream.rs:59–95  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

57
58#[test]
59fn test_stream_arrows_2() -> Result<(), StrError> {
60 // object and options
61 let mut stream = Stream::new();
62 let mut quiver = Stream::new();
63
64 // data
65 let n = 10;
66 let x = linspace(1.0, 2.0, n);
67 let y = x.clone();
68 let u = linspace(1.0, 2.0, n);
69 let v = u.clone();
70 let (uu, vv) = generate2d(1.0, 2.0, 1.0, 2.0, n, n);
71
72 // draw arrows
73 stream.set_streamline_zorder(1).draw_alt(&x, &y, &uu, &vv);
74 quiver
75 .set_quiver_zorder(2)
76 .set_color("red")
77 .set_quiver_inv_scale(20.0)
78 .draw_arrows_alt(&x, &y, &u, &v);
79
80 // add contour to plot
81 let mut plot = Plot::new();
82 plot.add(&stream).add(&quiver);
83
84 // save figure
85 let path = Path::new(OUT_DIR).join("integ_stream_arrows_2.svg");
86 plot.set_equal_axes(true).save(&path)?;
87
88 // check number of lines
89 let file = File::open(path).map_err(|_| "cannot open file")?;
90 let buffered = BufReader::new(file);
91 let lines_iter = buffered.lines();
92 let n = lines_iter.count();
93 assert!(n > 2000 && n < 3680);
94 Ok(())
95}

Callers

nothing calls this directly

Calls 11

linspaceFunction · 0.85
generate2dFunction · 0.85
draw_altMethod · 0.80
set_streamline_zorderMethod · 0.80
draw_arrows_altMethod · 0.80
set_quiver_inv_scaleMethod · 0.80
set_quiver_zorderMethod · 0.80
saveMethod · 0.80
set_equal_axesMethod · 0.80
set_colorMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected