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

Function vector_to_array

src/conversions.rs:30–41  ·  view source on GitHub ↗

Converts vector to a 1D NumPy array

(buf: &mut String, name: &str, vector: &'a T)

Source from the content-addressed store, hash-verified

28
29/// Converts vector to a 1D NumPy array
30pub(crate) fn vector_to_array<'a, T, U>(buf: &mut String, name: &str, vector: &'a T)
31where
32 T: AsVector<'a, U>,
33 U: 'a + std::fmt::Display + Num,
34{
35 write!(buf, "{}=np.array([", name).unwrap();
36 let m = vector.vec_size();
37 for i in 0..m {
38 write!(buf, "{},", vector.vec_at(i)).unwrap();
39 }
40 write!(buf, "])\n").unwrap();
41}
42
43/// Generates a nested Python list
44pub(crate) fn generate_nested_list<T>(buf: &mut String, name: &str, data: &Vec<Vec<T>>)

Callers 15

draw_triMethod · 0.85
contour_or_tricontourMethod · 0.85
draw_altMethod · 0.85
draw_arrows_altMethod · 0.85
drawMethod · 0.85
set_ticks_x_labelsMethod · 0.85
set_ticks_y_labelsMethod · 0.85
vector_to_array_worksFunction · 0.85
drawMethod · 0.85
draw_with_twin_xMethod · 0.85
draw_3dMethod · 0.85
draw_trianglesMethod · 0.85

Calls 1

vec_sizeMethod · 0.80

Tested by 1

vector_to_array_worksFunction · 0.68