Skip to content

Commit 83007bc

Browse files
author
Ioannis Giagkiozis
committed
updted dependency API usage
1 parent 557256c commit 83007bc

File tree

5 files changed

+24
-23
lines changed

5 files changed

+24
-23
lines changed

plotly/examples/basic_charts.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,21 +23,21 @@ fn simple_scatter_plot(show: bool) {
2323

2424
fn line_and_scatter_plots(show: bool) {
2525
let n: usize = 100;
26-
let rng = rand::thread_rng();
26+
let mut rng = rand::thread_rng();
2727
let random_x: Vec<f64> = linspace(0., 1., n).collect();
2828
let random_y0: Vec<f64> = Normal::new(5., 1.)
2929
.unwrap()
30-
.sample_iter(rng)
30+
.sample_iter(&mut rng)
3131
.take(n)
3232
.collect();
3333
let random_y1: Vec<f64> = Normal::new(0., 1.)
3434
.unwrap()
35-
.sample_iter(rng)
35+
.sample_iter(&mut rng)
3636
.take(n)
3737
.collect();
3838
let random_y2: Vec<f64> = Normal::new(-5., 1.)
3939
.unwrap()
40-
.sample_iter(rng)
40+
.sample_iter(&mut rng)
4141
.take(n)
4242
.collect();
4343

@@ -224,16 +224,16 @@ fn colored_and_styled_scatter_plot(show: bool) {
224224

225225
fn large_data_sets(show: bool) {
226226
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();
229229
let theta: Vec<f64> = Normal::new(0., 2. * std::f64::consts::PI)
230230
.unwrap()
231-
.sample_iter(rng)
231+
.sample_iter(&mut rng)
232232
.take(n)
233233
.collect();
234234
let colors: Vec<f64> = Normal::new(0., 1.)
235235
.unwrap()
236-
.sample_iter(rng)
236+
.sample_iter(&mut rng)
237237
.take(n)
238238
.collect();
239239

plotly/examples/fundamentals.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -419,35 +419,35 @@ fn circles_positioned_relative_to_the_axes(show: bool) {
419419
}
420420

421421
fn highlighting_clusters_of_scatter_points_with_circle_shapes(show: bool) {
422-
let rng = thread_rng();
422+
let mut rng = thread_rng();
423423
let x0 = Normal::new(2., 0.45)
424424
.unwrap()
425-
.sample_iter(rng)
425+
.sample_iter(&mut rng)
426426
.take(300)
427427
.collect::<Vec<f64>>();
428428
let y0 = Normal::new(2., 0.45)
429429
.unwrap()
430-
.sample_iter(rng)
430+
.sample_iter(&mut rng)
431431
.take(300)
432432
.collect::<Vec<f64>>();
433433
let x1 = Normal::new(6., 0.4)
434434
.unwrap()
435-
.sample_iter(rng)
435+
.sample_iter(&mut rng)
436436
.take(300)
437437
.collect::<Vec<f64>>();
438438
let y1 = Normal::new(6., 0.4)
439439
.unwrap()
440-
.sample_iter(rng)
440+
.sample_iter(&mut rng)
441441
.take(300)
442442
.collect::<Vec<f64>>();
443443
let x2 = Normal::new(4., 0.3)
444444
.unwrap()
445-
.sample_iter(rng)
445+
.sample_iter(&mut rng)
446446
.take(300)
447447
.collect::<Vec<f64>>();
448448
let y2 = Normal::new(4., 0.3)
449449
.unwrap()
450-
.sample_iter(rng)
450+
.sample_iter(&mut rng)
451451
.take(300)
452452
.collect::<Vec<f64>>();
453453

plotly/examples/ndarray_support.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn multiple_ndarray_traces_over_columns(show: bool) {
2424
let t: Array<f64, Ix1> = Array::range(0., 10., 10. / n as f64);
2525
let mut ys: Array<f64, Ix2> = Array::zeros((11, 11));
2626
let mut count = 0.;
27-
for mut row in ys.gencolumns_mut() {
27+
for mut row in ys.columns_mut() {
2828
for index in 0..row.len() {
2929
row[index] = count + (index as f64).powf(2.);
3030
}
@@ -49,7 +49,7 @@ fn multiple_ndarray_traces_over_rows(show: bool) {
4949
let t: Array<f64, Ix1> = Array::range(0., 10., 10. / n as f64);
5050
let mut ys: Array<f64, Ix2> = Array::zeros((11, 11));
5151
let mut count = 0.;
52-
for mut row in ys.gencolumns_mut() {
52+
for mut row in ys.columns_mut() {
5353
for index in 0..row.len() {
5454
row[index] = count + (index as f64).powf(2.);
5555
}

plotly/src/common/color.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use serde::Serialize;
22

3-
#[serde(untagged)]
43
#[derive(Serialize, Clone, Debug)]
4+
#[serde(untagged)]
55
pub enum ColorWrapper {
66
S(String),
77
F(f64),
@@ -383,13 +383,13 @@ impl Color for f64 {
383383

384384
fn string_types_to_color_wrapper<S: AsRef<str> + std::fmt::Display + Sized>(v: S) -> ColorWrapper {
385385
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);
387387
}
388388
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);
390390
}
391391
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);
393393
}
394394
let valid_characters = "#ABCDEF0123456789";
395395
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
398398
}
399399
for c in s.chars() {
400400
if !valid_characters.contains(c) {
401-
panic!(format!("{} is not a valid hex color!", v));
401+
panic!("{} is not a valid hex color!", v);
402402
}
403403
}
404404

plotly_kaleido/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use std::io::prelude::*;
1616
use std::io::BufReader;
1717
use std::path::{Path, PathBuf};
1818
use std::process::{Command, Stdio};
19+
use std::panic::panic_any;
1920

2021
#[derive(Serialize)]
2122
struct PlotData {
@@ -78,7 +79,7 @@ impl Kaleido {
7879
pub fn new() -> Kaleido {
7980
let path = match Kaleido::binary_path() {
8081
Ok(path) => path,
81-
Err(msg) => panic!(msg),
82+
Err(msg) => panic_any(msg),
8283
};
8384

8485
Kaleido { cmd_path: path }

0 commit comments

Comments
 (0)