Skip to content

Commit cf3608e

Browse files
author
Ioannis Giagkiozis
committed
Merge branch 'master' into dev
2 parents 416a9c6 + 83007bc commit cf3608e

File tree

10 files changed

+86
-70
lines changed

10 files changed

+86
-70
lines changed

.github/workflows/release_ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: build_linux
1919
run: cargo build --all-features --verbose
2020
- name: Run tests
21-
run: cargo test --workspace --verbose
21+
run: cargo test --all-features --release --verbose
2222

2323
build_windows:
2424
runs-on: windows-latest
@@ -28,7 +28,7 @@ jobs:
2828
- name: build_windows
2929
run: cargo build --all-features --verbose
3030
- name: Run tests
31-
run: cargo test --workspace --verbose
31+
run: cargo test --all-features --release --verbose
3232

3333
build_macos:
3434
runs-on: macos-latest
@@ -38,4 +38,4 @@ jobs:
3838
- name: build_macos
3939
run: cargo build --all-features --verbose
4040
- name: Run tests
41-
run: cargo test --workspace --verbose
41+
run: cargo test --all-features --release --verbose

CHANGELOG.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99
- tag matches for struct Axis : allow for synchronisation between subplots on x-axis
1010
- fn matches in impl of Axis
1111

12-
## [0.6.0] - 2020-xx-xx
12+
## [0.6.0] - 2020-07-25
1313
### Added
14-
- Shapes support (TODO add link to documentation and examples).
15-
- Annotations support (TODO add link to documentation and examples).
16-
- Docstrings.
17-
- `ndarray` support (TODO add link to documentation and examples).
18-
- Jupyter lab support (TODO add link to documentation and examples).
14+
- Shapes support ([documentation](https://igiagkiozis.github.io/plotly/content/fundamentals/shapes.html)).
15+
- Annotations support.
16+
- Docstrings to `Scatter`.
17+
- `ndarray` support ([documentation](https://igiagkiozis.github.io/plotly/content/fundamentals/ndarray_support.html)).
18+
- Jupyter lab and notebook support ([documentation](https://igiagkiozis.github.io/plotly/content/fundamentals/jupyter_support.html)).
1919
### Changed
2020
- Removed `num` dependence.
2121
- Removed `plotly_orca` and the `orca` feature. Use the `kaleido` feature for static image generation.
2222
- Updated Kaleido version in `plotly_kaleido` to 0.0.1.
23-
### Fixed
24-
- xx
23+
2524

2625
## [0.5.1] - 2020-07-12
2726
### Added

plotly/Cargo.toml

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ repository = "https://github.com/igiagkiozis/plotly"
1212
edition = "2018"
1313
keywords = ["plot", "chart", "plotly"]
1414

15-
exclude = [
16-
"target/*"
17-
]
15+
exclude = ["target/*"]
1816

1917
[features]
2018
# Adds plot save functionality to the following formats: png, jpeg, webp, svg, pdf and eps.
@@ -23,17 +21,17 @@ plotly_ndarray = ["ndarray"]
2321

2422
[dependencies]
2523
plotly_kaleido = { version = "0.2.0", path = "../plotly_kaleido", optional = true }
26-
ndarray = { version = ">=0.13.1", optional = true }
27-
serde = { version = "1.0", features = ["derive"] }
28-
serde_json = "1.0"
29-
askama = "0.9.0"
30-
rand = "0.7.3"
31-
rand_distr = "0.2.2"
24+
ndarray = { version = "0.15.1", optional = true }
25+
serde = { version = "1.0.125", features = ["derive"] }
26+
serde_json = "1.0.64"
27+
askama = "0.10.5"
28+
rand = "0.8.3"
29+
rand_distr = "0.4.0"
3230

3331

3432
[dev-dependencies]
3533
plotly_kaleido = { version = "0.2.0", path = "../plotly_kaleido" }
36-
itertools = "0.9.0"
34+
itertools = "0.10.0"
3735
itertools-num = "0.1.3"
38-
csv = "1.1.3"
39-
ndarray = "0.13.1"
36+
csv = "1.1.6"
37+
ndarray = "0.15.1"

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/src/plot.rs

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ pub enum ImageFormat {
5454
EPS,
5555
}
5656

57-
5857
/// A struct that implements `Trace` can be serialized to json format that is understood by Plotly.js.
5958
pub trait Trace {
6059
fn serialize(&self) -> String;
@@ -120,7 +119,6 @@ plot.save("filename", ImageFormat::PNG, width, height, scale);
120119
See https://igiagkiozis.github.io/plotly/content/getting_started.html for further details.
121120
"#;
122121

123-
124122
impl Plot {
125123
/// Create a new `Plot`.
126124
pub fn new() -> Plot {
@@ -164,10 +162,13 @@ impl Plot {
164162
let rendered = rendered.as_bytes();
165163
let mut temp = env::temp_dir();
166164

167-
let mut plot_name = rand::thread_rng()
168-
.sample_iter(&rand::distributions::Alphanumeric)
169-
.take(22)
170-
.collect::<String>();
165+
let mut plot_name = String::from_utf8(
166+
thread_rng()
167+
.sample_iter(&Alphanumeric)
168+
.take(22)
169+
.collect::<Vec<u8>>(),
170+
)
171+
.unwrap();
171172
plot_name.push_str(".html");
172173
plot_name = format!("plotly_{}", plot_name);
173174

@@ -191,10 +192,13 @@ impl Plot {
191192
let rendered = rendered.as_bytes();
192193
let mut temp = env::temp_dir();
193194

194-
let mut plot_name = rand::thread_rng()
195-
.sample_iter(&rand::distributions::Alphanumeric)
196-
.take(22)
197-
.collect::<String>();
195+
let mut plot_name = String::from_utf8(
196+
thread_rng()
197+
.sample_iter(&Alphanumeric)
198+
.take(22)
199+
.collect::<Vec<u8>>(),
200+
)
201+
.unwrap();
198202
plot_name.push_str(".html");
199203

200204
temp.push(plot_name);
@@ -217,10 +221,13 @@ impl Plot {
217221
let rendered = rendered.as_bytes();
218222
let mut temp = env::temp_dir();
219223

220-
let mut plot_name = rand::thread_rng()
221-
.sample_iter(&rand::distributions::Alphanumeric)
222-
.take(22)
223-
.collect::<String>();
224+
let mut plot_name: String = String::from_utf8(
225+
thread_rng()
226+
.sample_iter(&Alphanumeric)
227+
.take(22)
228+
.collect::<Vec<u8>>(),
229+
)
230+
.unwrap();
224231
plot_name.push_str(".html");
225232

226233
temp.push(plot_name);
@@ -260,14 +267,26 @@ impl Plot {
260267
match plot_div_id {
261268
Some(id) => self.render_inline(id.as_ref()),
262269
None => {
263-
let rand_id: String = thread_rng().sample_iter(&Alphanumeric).take(20).collect();
270+
let rand_id = String::from_utf8(
271+
thread_rng()
272+
.sample_iter(&Alphanumeric)
273+
.take(20)
274+
.collect::<Vec<u8>>(),
275+
)
276+
.unwrap();
264277
self.render_inline(rand_id.as_str())
265278
}
266279
}
267280
}
268281

269282
fn to_jupyter_notebook_html(&self) -> String {
270-
let plot_div_id: String = thread_rng().sample_iter(&Alphanumeric).take(20).collect();
283+
let plot_div_id = String::from_utf8(
284+
thread_rng()
285+
.sample_iter(&Alphanumeric)
286+
.take(20)
287+
.collect::<Vec<u8>>(),
288+
)
289+
.unwrap();
271290
let plot_data = self.render_plot_data();
272291

273292
let tmpl = JupyterNotebookPlotTemplate {
@@ -280,7 +299,10 @@ impl Plot {
280299
/// Display plot in Jupyter Notebook.
281300
pub fn notebook_display(&self) {
282301
let plot_data = self.to_jupyter_notebook_html();
283-
println!("EVCXR_BEGIN_CONTENT text/html\n{}\nEVCXR_END_CONTENT", plot_data);
302+
println!(
303+
"EVCXR_BEGIN_CONTENT text/html\n{}\nEVCXR_END_CONTENT",
304+
plot_data
305+
);
284306
}
285307

286308
/// Display plot in Jupyter Lab.

plotly_kaleido/Cargo.toml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,15 @@ repository = "https://github.com/igiagkiozis/plotly"
1212
edition = "2018"
1313
keywords = ["plot", "chart", "plotly", "ndarray"]
1414

15-
exclude = [
16-
"target/*",
17-
"kaleido/*",
18-
"examples/*"
19-
]
15+
exclude = ["target/*", "kaleido/*", "examples/*"]
2016

2117
[dependencies]
2218
serde = { version = "1.0", features = ["derive"] }
2319
serde_json = "1.0"
24-
base64 = "0.12.3"
20+
base64 = "0.13.0"
2521

2622
[dev-dependencies]
2723
zip = "0.5.6"
2824

2925
[build-dependencies]
30-
zip = "0.5.6"
26+
zip = "0.5.6"

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)