Skip to content

Commit b330f45

Browse files
committed
add rustfmt configuration, changed max line width to something more reasonable
1 parent e117cb3 commit b330f45

File tree

6 files changed

+14
-26
lines changed

6 files changed

+14
-26
lines changed

rustfmt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
max_width = 200

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,22 @@
77
//! use dataplotlib::util::{linspace, zip2};
88
//! use dataplotlib::plotbuilder::PlotBuilder2D;
99
//! use dataplotlib::plotter::Plotter;
10-
//!
10+
//!
1111
//! fn main() {
1212
//! let x = linspace(0, 10, 100);
13-
//!
13+
//!
1414
//! let y_sin = x.iter().map(|x| x.sin()).collect();
1515
//! let xy_sin = zip2(&x, &y_sin);
16-
//!
16+
//!
1717
//! let xy_lin = zip2(&x, &x);
18-
//!
18+
//!
1919
//! // Creates a new plot builder
2020
//! let mut pb = PlotBuilder2D::new();
21-
//!
21+
//!
2222
//! // Adds the sin plot and the linear plot with custom colors
2323
//! pb.add_color_xy(xy_sin, [1.0, 0.0, 0.0, 1.0]);
2424
//! pb.add_color_xy(xy_lin, [0.0, 0.0, 1.0, 1.0]);
25-
//!
25+
//!
2626
//! let mut plt = Plotter::new();
2727
//! plt.plot2d(pb);
2828
//! plt.join();

src/plot.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,7 @@ fn get_min(user_min: Option<f64>, values: &Vec<f64>) -> f64 {
5151
}
5252
}
5353

54-
fn draw_borders(bordercol: [f32; 4],
55-
bgcol: [f32; 4],
56-
space: f64,
57-
m: f64,
58-
transform: [[f64; 3]; 2],
59-
g: &mut piston_window::G2d) {
54+
fn draw_borders(bordercol: [f32; 4], bgcol: [f32; 4], space: f64, m: f64, transform: [[f64; 3]; 2], g: &mut piston_window::G2d) {
6055
clear(bordercol, g);
6156
rectangle([0.0, 0.0, 1.0, 1.0],
6257
[space - 2.0, space - 2.0, m + 4.0, m + 4.0], // rectangle
@@ -80,11 +75,7 @@ fn set_xy(xy: &Vec<(f64, f64)>, x_vector: &mut Vec<Vec<f64>>, y_vector: &mut Vec
8075
}
8176
}
8277

83-
fn draw_plots(window: &mut PistonWindow,
84-
xs: &Vec<Vec<f64>>,
85-
ys: &Vec<Vec<f64>>,
86-
colors: &Vec<[f32; 4]>,
87-
plot_bounds: [f64; 4]) {
78+
fn draw_plots(window: &mut PistonWindow, xs: &Vec<Vec<f64>>, ys: &Vec<Vec<f64>>, colors: &Vec<[f32; 4]>, plot_bounds: [f64; 4]) {
8879
let bordercol = [0.95, 0.95, 0.95, 1.0];
8980
let bgcol = [1.0, 1.0, 1.0, 1.0];
9081
let margin = 0.05;
@@ -110,8 +101,7 @@ fn draw_plots(window: &mut PistonWindow,
110101

111102
for i in 0..colors.len() {
112103
let color = colors[i];
113-
let xt: Vec<f64> =
114-
xs[i].iter().map(|x| point2plot(*x, x_min, x_max, m, space)).collect();
104+
let xt: Vec<f64> = xs[i].iter().map(|x| point2plot(*x, x_min, x_max, m, space)).collect();
115105
let yt: Vec<f64> = ys[i]
116106
.iter()
117107
.map(|y| (2.0 * space + m) - point2plot(*y, y_min, y_max, m, space))
@@ -134,10 +124,7 @@ fn draw_plots(window: &mut PistonWindow,
134124
}
135125
}
136126

137-
fn get_plot_bounds(plot_builder: &PlotBuilder2D,
138-
xs: &Vec<Vec<f64>>,
139-
ys: &Vec<Vec<f64>>)
140-
-> [f64; 4] {
127+
fn get_plot_bounds(plot_builder: &PlotBuilder2D, xs: &Vec<Vec<f64>>, ys: &Vec<Vec<f64>>) -> [f64; 4] {
141128

142129
let mut max_xs: Vec<f64> = Vec::new();
143130
let mut max_ys: Vec<f64> = Vec::new();

src/plotbuilder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,4 +104,4 @@ impl PlotBuilder2D {
104104
pub fn add_fun_xy(&mut self, fun: PlotFn) {
105105
self.pvs.push(PlotVals2D::FunColor([1.0, 0.0, 0.0, 1.0], fun));
106106
}
107-
}
107+
}

src/plotter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ mod test {
5454
plt.plot2d(pb1);
5555
plt.join();
5656
}
57-
}
57+
}

src/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ pub fn zip2<T>(a: &Vec<T>, b: &Vec<T>) -> Vec<(T, T)>
2828
ret.push((a[i], b[i]));
2929
}
3030
return ret;
31-
}
31+
}

0 commit comments

Comments
 (0)