Showing 7 of 17 files from the diff.

@@ -53,7 +53,10 @@
Loading
53 53
/// Floor or ceiling the min or max to zero to avoid them both having the same value
54 54
pub fn pad_range_to_zero(min: f64, max: f64) -> (f64, f64) {
55 55
    if (min - max).abs() < std::f64::EPSILON {
56 -
        (if min > 0. {0.} else {min}, if max < 0. {0.} else {max})
56 +
        (
57 +
            if min > 0. { 0. } else { min },
58 +
            if max < 0. { 0. } else { max },
59 +
        )
57 60
    } else {
58 61
        (min, max)
59 62
    }

@@ -31,7 +31,6 @@
Loading
31 31
use crate::text_render;
32 32
use crate::utils::PairWise;
33 33
34 -
35 34
#[derive(Debug)]
36 35
enum HistogramType {
37 36
    Count,
@@ -212,7 +211,8 @@
Loading
212 211
            [0., 1. / 3., 2. / 3., 1.]
213 212
        );
214 213
        assert_eq!(
215 -
            Histogram::from_slice(&[], HistogramBins::Bounds([0., 1., 1.5, 2., 5.6].to_vec())).bin_bounds,
214 +
            Histogram::from_slice(&[], HistogramBins::Bounds([0., 1., 1.5, 2., 5.6].to_vec()))
215 +
                .bin_bounds,
216 216
            [0., 1., 1.5, 2., 5.6]
217 217
        );
218 218
    }

@@ -83,7 +83,6 @@
Loading
83 83
    Cross,
84 84
}
85 85
86 -
87 86
#[derive(Debug, Default, Clone)]
88 87
pub struct PointStyle {
89 88
    marker: Option<PointMarker>,
@@ -146,7 +145,6 @@
Loading
146 145
    }
147 146
}
148 147
149 -
150 148
#[derive(Debug, Default)]
151 149
pub struct BoxStyle {
152 150
    fill: Option<String>,
@@ -172,7 +170,6 @@
Loading
172 170
    pub fn get_fill(&self) -> String {
173 171
        self.fill.clone().unwrap_or_else(|| "".into())
174 172
    }
175 -
176 173
}
177 174
178 175
#[cfg(test)]
@@ -182,7 +179,12 @@
Loading
182 179
    #[test]
183 180
    fn test_linestyle_plain_overlay() {
184 181
        let mut p = LineStyle::new();
185 -
        p.overlay(&LineStyle::new().colour("red").linejoin(LineJoin::Miter).width(1.));
182 +
        p.overlay(
183 +
            &LineStyle::new()
184 +
                .colour("red")
185 +
                .linejoin(LineJoin::Miter)
186 +
                .width(1.),
187 +
        );
186 188
        assert_eq!(p.get_colour(), "red".to_string());
187 189
        assert_eq!(p.get_width(), 1.);
188 190
        if let LineJoin::Miter = p.get_linejoin() {

@@ -110,9 +110,14 @@
Loading
110 110
        labels.append(tick_label);
111 111
    }
112 112
113 -
    let max_tick_length = a.ticks().iter().map(|&t| t.to_string().len()).max().expect("Could not calculate max tick length");
114 -
115 -
    let x_offset = -(y_tick_font_size*max_tick_length as i32);
113 +
    let max_tick_length = a
114 +
        .ticks()
115 +
        .iter()
116 +
        .map(|&t| t.to_string().len())
117 +
        .max()
118 +
        .expect("Could not calculate max tick length");
119 +
120 +
    let x_offset = -(y_tick_font_size * max_tick_length as i32);
116 121
    let y_label_offset = -(face_height / 2.);
117 122
    let y_label_font_size = 12;
118 123
    let label = node::element::Text::new()
@@ -188,8 +193,7 @@
Loading
188 193
    face_width: f64,
189 194
    face_height: f64,
190 195
    style: &style::PointStyle,
191 -
) -> node::element::Group
192 -
{
196 +
) -> node::element::Group {
193 197
    let mut group = node::element::Group::new();
194 198
195 199
    for &(x, y) in s {
@@ -203,10 +207,7 @@
Loading
203 207
                        .set("cx", x_pos)
204 208
                        .set("cy", y_pos)
205 209
                        .set("r", radius)
206 -
                        .set(
207 -
                            "fill",
208 -
                            style.get_colour(),
209 -
                        ),
210 +
                        .set("fill", style.get_colour()),
210 211
                );
211 212
            }
212 213
            style::PointMarker::Square => {
@@ -216,10 +217,7 @@
Loading
216 217
                        .set("y", y_pos - radius)
217 218
                        .set("width", 2. * radius)
218 219
                        .set("height", 2. * radius)
219 -
                        .set(
220 -
                            "fill",
221 -
                            style.get_colour(),
222 -
                        ),
220 +
                        .set("fill", style.get_colour()),
223 221
                );
224 222
            }
225 223
            style::PointMarker::Cross => {
@@ -232,10 +230,7 @@
Loading
232 230
                group.append(
233 231
                    node::element::Path::new()
234 232
                        .set("fill", "none")
235 -
                        .set(
236 -
                            "stroke",
237 -
                            style.get_colour(),
238 -
                        )
233 +
                        .set("stroke", style.get_colour())
239 234
                        .set("stroke-width", 2)
240 235
                        .set("d", path),
241 236
                );
@@ -253,8 +248,7 @@
Loading
253 248
    face_width: f64,
254 249
    face_height: f64,
255 250
    style: &style::BoxStyle,
256 -
) -> node::element::Group
257 -
{
251 +
) -> node::element::Group {
258 252
    let mut group = node::element::Group::new();
259 253
260 254
    for ((&l, &u), &count) in h.bin_bounds.pairwise().zip(h.get_values()) {
@@ -267,11 +261,7 @@
Loading
267 261
            .set("y", -count_scaled)
268 262
            .set("width", width)
269 263
            .set("height", count_scaled)
270 -
            .set(
271 -
                "fill",
272 -
                style
273 -
                    .get_fill()
274 -
            )
264 +
            .set("fill", style.get_fill())
275 265
            .set("stroke", "black");
276 266
        group.append(rect);
277 267
    }
@@ -286,8 +276,7 @@
Loading
286 276
    face_width: f64,
287 277
    face_height: f64,
288 278
    style: &style::LineStyle,
289 -
) -> node::element::Group
290 -
{
279 +
) -> node::element::Group {
291 280
    let mut group = node::element::Group::new();
292 281
293 282
    let mut d: Vec<node::element::path::Command> = vec![];
@@ -314,10 +303,13 @@
Loading
314 303
            .set("fill", "none")
315 304
            .set("stroke", style.get_colour())
316 305
            .set("stroke-width", style.get_width())
317 -
            .set("stroke-linejoin", match style.get_linejoin() {
318 -
                style::LineJoin::Miter => "miter",
319 -
                style::LineJoin::Round => "round",
320 -
            })
306 +
            .set(
307 +
                "stroke-linejoin",
308 +
                match style.get_linejoin() {
309 +
                    style::LineJoin::Miter => "miter",
310 +
                    style::LineJoin::Round => "round",
311 +
                },
312 +
            )
321 313
            .set("d", path),
322 314
    );
323 315
@@ -427,7 +419,7 @@
Loading
427 419
            .set("y", box_start)
428 420
            .set("width", box_width)
429 421
            .set("height", box_end - box_start)
430 -
            .set("fill", style .get_fill())
422 +
            .set("fill", style.get_fill())
431 423
            .set("stroke", "black"),
432 424
    );
433 425

@@ -109,9 +109,7 @@
Loading
109 109
    fn start_at(start: f64) -> TickSteps {
110 110
        let start_options = TickSteps::scaled_steps(start);
111 111
        let overflow = start_options[0] * 10.0;
112 -
        let curr = start_options
113 -
            .iter()
114 -
            .find(|&step| step >= &start);
112 +
        let curr = start_options.iter().find(|&step| step >= &start);
115 113
116 114
        TickSteps {
117 115
            next: *curr.unwrap_or(&overflow),
@@ -135,10 +133,7 @@
Loading
135 133
        let curr = self.next; // cache the value we're currently on
136 134
        let curr_steps = TickSteps::scaled_steps(self.next);
137 135
        let overflow = curr_steps[0] * 10.0;
138 -
        self.next = *curr_steps
139 -
            .iter()
140 -
            .find(|&s| s > &curr)
141 -
            .unwrap_or(&overflow);
136 +
        self.next = *curr_steps.iter().find(|&s| s > &curr).unwrap_or(&overflow);
142 137
        Some(curr)
143 138
    }
144 139
}

@@ -123,7 +123,8 @@
Loading
123 123
        .map(|(&offset, &tick)| XAxisLabel {
124 124
            text: tick.to_string(),
125 125
            offset,
126 -
        }).collect();
126 +
        })
127 +
        .collect();
127 128
    ls.sort_by_key(|l| l.offset);
128 129
    ls
129 130
}
@@ -151,14 +152,16 @@
Loading
151 152
        .map(|line| match y_tick_map.get(&(line as i32)) {
152 153
            Some(v) => v.to_string(),
153 154
            None => "".to_string(),
154 -
        }).collect();
155 +
        })
156 +
        .collect();
155 157
156 158
    // Generate a list of strings to tick the y-axis
157 159
    let y_tick_strings: Vec<_> = (0..=face_height)
158 160
        .map(|line| match y_tick_map.get(&(line as i32)) {
159 161
            Some(_) => "-".to_string(),
160 162
            None => " ".to_string(),
161 -
        }).collect();
163 +
        })
164 +
        .collect();
162 165
163 166
    // Generate a list of strings to be the y-axis line itself
164 167
    let y_axis_line_strings: Vec<String> = std::iter::repeat('+')
@@ -185,7 +188,8 @@
Loading
185 188
                a,
186 189
                num_width = longest_y_label_width
187 190
            )
188 -
        }).collect();
191 +
        })
192 +
        .collect();
189 193
190 194
    let axis_string = axis_string.join("\n");
191 195
@@ -201,7 +205,8 @@
Loading
201 205
        .map(|cell| match x_tick_map.get(&(cell as i32)) {
202 206
            Some(_) => '|',
203 207
            None => ' ',
204 -
        }).collect();
208 +
        })
209 +
        .collect();
205 210
206 211
    // Create a string which will be printed to give the x-axis labels
207 212
    let x_labels = create_x_axis_labels(&x_tick_map);
@@ -287,11 +292,12 @@
Loading
287 292
        .map(|&bin| match bin {
288 293
            None => 0,
289 294
            Some(b) => value_to_axis_cell_offset(h.get_values()[b as usize], y_axis, face_height),
290 -
        }).collect();
295 +
        })
296 +
        .collect();
291 297
292 298
    let mut face_strings: Vec<String> = vec![];
293 299
294 -
    for line in 1..=face_height  {
300 +
    for line in 1..=face_height {
295 301
        let mut line_string = String::new();
296 302
        for column in 1..=face_width as usize {
297 303
            // maybe use a HashSet for faster `contains()`?
@@ -350,8 +356,7 @@
Loading
350 356
    face_width: u32,
351 357
    face_height: u32,
352 358
    style: &style::PointStyle,
353 -
) -> String
354 -
{
359 +
) -> String {
355 360
    let points: Vec<_> = s
356 361
        .iter()
357 362
        .map(|&(x, y)| {
@@ -359,7 +364,8 @@
Loading
359 364
                value_to_axis_cell_offset(x, x_axis, face_width),
360 365
                value_to_axis_cell_offset(y, y_axis, face_height),
361 366
            )
362 -
        }).collect();
367 +
        })
368 +
        .collect();
363 369
364 370
    let marker = match style.get_marker() {
365 371
        style::PointMarker::Circle => '●',
@@ -447,7 +453,8 @@
Loading
447 453
                l.chars()
448 454
                    .chain((0..line_width_deficit).map(|_| ' '))
449 455
                    .collect()
450 -
            }).collect()
456 +
            })
457 +
            .collect()
451 458
    } else {
452 459
        split_over
453 460
    };
@@ -609,7 +616,8 @@
Loading
609 616
            " |     | |---- -----",
610 617
            " |     | | | | | | |",
611 618
            " |     | | | | | | |",
612 -
        ].join("\n");
619 +
        ]
620 +
        .join("\n");
613 621
614 622
        assert_eq!(&strings, &comp);
615 623
    }
@@ -644,7 +652,8 @@
Loading
644 652
            "     ●              ",
645 653
            "                    ",
646 654
            "                    ",
647 -
        ].join("\n");
655 +
        ]
656 +
        .join("\n");
648 657
649 658
        assert_eq!(&strings, &comp);
650 659
    }

@@ -78,7 +78,6 @@
Loading
78 78
        self
79 79
    }
80 80
81 -
82 81
    fn x_range(&self) -> (f64, f64) {
83 82
        let mut min = f64::INFINITY;
84 83
        let mut max = f64::NEG_INFINITY;
@@ -118,26 +117,24 @@
Loading
118 117
    ) -> svg::node::element::Group {
119 118
        let mut group = node::element::Group::new();
120 119
        if let Some(ref line_style) = self.line_style {
121 -
            group.append(
122 -
                svg_render::draw_face_line(
123 -
                    &self.data,
124 -
                    x_axis,
125 -
                    y_axis,
126 -
                    face_width,
127 -
                    face_height,
128 -
                    line_style,
129 -
                ))
120 +
            group.append(svg_render::draw_face_line(
121 +
                &self.data,
122 +
                x_axis,
123 +
                y_axis,
124 +
                face_width,
125 +
                face_height,
126 +
                line_style,
127 +
            ))
130 128
        }
131 129
        if let Some(ref point_style) = self.point_style {
132 -
            group.append(
133 -
                svg_render::draw_face_points(
134 -
                    &self.data,
135 -
                    x_axis,
136 -
                    y_axis,
137 -
                    face_width,
138 -
                    face_height,
139 -
                    point_style,
140 -
                ))
130 +
            group.append(svg_render::draw_face_points(
131 +
                &self.data,
132 +
                x_axis,
133 +
                y_axis,
134 +
                face_width,
135 +
                face_height,
136 +
                point_style,
137 +
            ))
141 138
        }
142 139
        group
143 140
    }
@@ -162,9 +159,9 @@
Loading
162 159
            if let Some(ref style) = self.line_style {
163 160
                let line = node::element::Line::new()
164 161
                    .set("x1", -10)
165 -
                    .set("y1", -FONT_SIZE/2. +2.)
162 +
                    .set("y1", -FONT_SIZE / 2. + 2.)
166 163
                    .set("x2", -3)
167 -
                    .set("y2", -FONT_SIZE/2. +2.)
164 +
                    .set("y2", -FONT_SIZE / 2. + 2.)
168 165
                    .set("stroke-width", style.get_width())
169 166
                    .set("stroke", style.get_colour());
170 167
                group.append(line);
Files Coverage
src 60.00%
tests/test_no_data.rs 100.00%
Project Totals (15 files) 60.75%
Untitled

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading