File tree Expand file tree Collapse file tree 5 files changed +24
-23
lines changed Expand file tree Collapse file tree 5 files changed +24
-23
lines changed Original file line number Diff line number Diff line change @@ -23,21 +23,21 @@ fn simple_scatter_plot(show: bool) {
23
23
24
24
fn line_and_scatter_plots ( show : bool ) {
25
25
let n: usize = 100 ;
26
- let rng = rand:: thread_rng ( ) ;
26
+ let mut rng = rand:: thread_rng ( ) ;
27
27
let random_x: Vec < f64 > = linspace ( 0. , 1. , n) . collect ( ) ;
28
28
let random_y0: Vec < f64 > = Normal :: new ( 5. , 1. )
29
29
. unwrap ( )
30
- . sample_iter ( rng)
30
+ . sample_iter ( & mut rng)
31
31
. take ( n)
32
32
. collect ( ) ;
33
33
let random_y1: Vec < f64 > = Normal :: new ( 0. , 1. )
34
34
. unwrap ( )
35
- . sample_iter ( rng)
35
+ . sample_iter ( & mut rng)
36
36
. take ( n)
37
37
. collect ( ) ;
38
38
let random_y2: Vec < f64 > = Normal :: new ( -5. , 1. )
39
39
. unwrap ( )
40
- . sample_iter ( rng)
40
+ . sample_iter ( & mut rng)
41
41
. take ( n)
42
42
. collect ( ) ;
43
43
@@ -224,16 +224,16 @@ fn colored_and_styled_scatter_plot(show: bool) {
224
224
225
225
fn large_data_sets ( show : bool ) {
226
226
let n: usize = 100_000 ;
227
- let rng = rand:: thread_rng ( ) ;
228
- let r: Vec < f64 > = Uniform :: new ( 0. , 1. ) . sample_iter ( rng) . take ( n) . collect ( ) ;
227
+ let mut rng = rand:: thread_rng ( ) ;
228
+ let r: Vec < f64 > = Uniform :: new ( 0. , 1. ) . sample_iter ( & mut rng) . take ( n) . collect ( ) ;
229
229
let theta: Vec < f64 > = Normal :: new ( 0. , 2. * std:: f64:: consts:: PI )
230
230
. unwrap ( )
231
- . sample_iter ( rng)
231
+ . sample_iter ( & mut rng)
232
232
. take ( n)
233
233
. collect ( ) ;
234
234
let colors: Vec < f64 > = Normal :: new ( 0. , 1. )
235
235
. unwrap ( )
236
- . sample_iter ( rng)
236
+ . sample_iter ( & mut rng)
237
237
. take ( n)
238
238
. collect ( ) ;
239
239
Original file line number Diff line number Diff line change @@ -419,35 +419,35 @@ fn circles_positioned_relative_to_the_axes(show: bool) {
419
419
}
420
420
421
421
fn highlighting_clusters_of_scatter_points_with_circle_shapes ( show : bool ) {
422
- let rng = thread_rng ( ) ;
422
+ let mut rng = thread_rng ( ) ;
423
423
let x0 = Normal :: new ( 2. , 0.45 )
424
424
. unwrap ( )
425
- . sample_iter ( rng)
425
+ . sample_iter ( & mut rng)
426
426
. take ( 300 )
427
427
. collect :: < Vec < f64 > > ( ) ;
428
428
let y0 = Normal :: new ( 2. , 0.45 )
429
429
. unwrap ( )
430
- . sample_iter ( rng)
430
+ . sample_iter ( & mut rng)
431
431
. take ( 300 )
432
432
. collect :: < Vec < f64 > > ( ) ;
433
433
let x1 = Normal :: new ( 6. , 0.4 )
434
434
. unwrap ( )
435
- . sample_iter ( rng)
435
+ . sample_iter ( & mut rng)
436
436
. take ( 300 )
437
437
. collect :: < Vec < f64 > > ( ) ;
438
438
let y1 = Normal :: new ( 6. , 0.4 )
439
439
. unwrap ( )
440
- . sample_iter ( rng)
440
+ . sample_iter ( & mut rng)
441
441
. take ( 300 )
442
442
. collect :: < Vec < f64 > > ( ) ;
443
443
let x2 = Normal :: new ( 4. , 0.3 )
444
444
. unwrap ( )
445
- . sample_iter ( rng)
445
+ . sample_iter ( & mut rng)
446
446
. take ( 300 )
447
447
. collect :: < Vec < f64 > > ( ) ;
448
448
let y2 = Normal :: new ( 4. , 0.3 )
449
449
. unwrap ( )
450
- . sample_iter ( rng)
450
+ . sample_iter ( & mut rng)
451
451
. take ( 300 )
452
452
. collect :: < Vec < f64 > > ( ) ;
453
453
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ fn multiple_ndarray_traces_over_columns(show: bool) {
24
24
let t: Array < f64 , Ix1 > = Array :: range ( 0. , 10. , 10. / n as f64 ) ;
25
25
let mut ys: Array < f64 , Ix2 > = Array :: zeros ( ( 11 , 11 ) ) ;
26
26
let mut count = 0. ;
27
- for mut row in ys. gencolumns_mut ( ) {
27
+ for mut row in ys. columns_mut ( ) {
28
28
for index in 0 ..row. len ( ) {
29
29
row[ index] = count + ( index as f64 ) . powf ( 2. ) ;
30
30
}
@@ -49,7 +49,7 @@ fn multiple_ndarray_traces_over_rows(show: bool) {
49
49
let t: Array < f64 , Ix1 > = Array :: range ( 0. , 10. , 10. / n as f64 ) ;
50
50
let mut ys: Array < f64 , Ix2 > = Array :: zeros ( ( 11 , 11 ) ) ;
51
51
let mut count = 0. ;
52
- for mut row in ys. gencolumns_mut ( ) {
52
+ for mut row in ys. columns_mut ( ) {
53
53
for index in 0 ..row. len ( ) {
54
54
row[ index] = count + ( index as f64 ) . powf ( 2. ) ;
55
55
}
Original file line number Diff line number Diff line change 1
1
use serde:: Serialize ;
2
2
3
- #[ serde( untagged) ]
4
3
#[ derive( Serialize , Clone , Debug ) ]
4
+ #[ serde( untagged) ]
5
5
pub enum ColorWrapper {
6
6
S ( String ) ,
7
7
F ( f64 ) ,
@@ -383,13 +383,13 @@ impl Color for f64 {
383
383
384
384
fn string_types_to_color_wrapper < S : AsRef < str > + std:: fmt:: Display + Sized > ( v : S ) -> ColorWrapper {
385
385
if v. as_ref ( ) . len ( ) < 6 || v. as_ref ( ) . len ( ) > 7 {
386
- panic ! ( format! ( "{} is not a valid hex color!" , v) ) ;
386
+ panic ! ( "{} is not a valid hex color!" , v) ;
387
387
}
388
388
if v. as_ref ( ) . len ( ) == 6 && v. as_ref ( ) . starts_with ( '#' ) {
389
- panic ! ( format! ( "{} is not a valid hex color!" , v) ) ;
389
+ panic ! ( "{} is not a valid hex color!" , v) ;
390
390
}
391
391
if v. as_ref ( ) . len ( ) == 7 && !v. as_ref ( ) . starts_with ( '#' ) {
392
- panic ! ( format! ( "{} is not a valid hex color!" , v) ) ;
392
+ panic ! ( "{} is not a valid hex color!" , v) ;
393
393
}
394
394
let valid_characters = "#ABCDEF0123456789" ;
395
395
let mut s = v. as_ref ( ) . to_uppercase ( ) ;
@@ -398,7 +398,7 @@ fn string_types_to_color_wrapper<S: AsRef<str> + std::fmt::Display + Sized>(v: S
398
398
}
399
399
for c in s. chars ( ) {
400
400
if !valid_characters. contains ( c) {
401
- panic ! ( format! ( "{} is not a valid hex color!" , v) ) ;
401
+ panic ! ( "{} is not a valid hex color!" , v) ;
402
402
}
403
403
}
404
404
Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ use std::io::prelude::*;
16
16
use std:: io:: BufReader ;
17
17
use std:: path:: { Path , PathBuf } ;
18
18
use std:: process:: { Command , Stdio } ;
19
+ use std:: panic:: panic_any;
19
20
20
21
#[ derive( Serialize ) ]
21
22
struct PlotData {
@@ -78,7 +79,7 @@ impl Kaleido {
78
79
pub fn new ( ) -> Kaleido {
79
80
let path = match Kaleido :: binary_path ( ) {
80
81
Ok ( path) => path,
81
- Err ( msg) => panic ! ( msg) ,
82
+ Err ( msg) => panic_any ( msg) ,
82
83
} ;
83
84
84
85
Kaleido { cmd_path : path }
You can’t perform that action at this time.
0 commit comments