From 2d96f5574a4deeb34daad0efb36a86966b79dd5e Mon Sep 17 00:00:00 2001 From: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com> Date: Tue, 31 Dec 2024 13:16:31 +0100 Subject: [PATCH 1/3] update changelog Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com> --- CHANGELOG.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cf2ea1b..bb499e5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,11 +3,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.11.1] - 2024-12-X +## [0.12.0] - 2024-12-31 ### Changed -- +- [[#256](https://github.com/plotly/plotly.rs/pull/256)] Bump Cargo.toml edition to 2021 +- [[#261](https://github.com/plotly/plotly.rs/pull/261)] Updated code of conduct ### Fixed +- [[#265](https://github.com/plotly/plotly.rs/pull/265)] Add Pie Chart trace +- [[#216](https://github.com/plotly/plotly.rs/issues/216)] Opt out of downloading Kaleido binaries and allow users to set Kaleido path via environment variable +- [[#259](https://github.com/plotly/plotly.rs/issues/259)] Mesh3d::new() has wrong signature - [[#175](https://github.com/plotly/plotly.rs/issues/175)] Put multiple subplots in the same html - added an example using `build_html` crate. - [[#228](https://github.com/plotly/plotly.rs/issues/228)] Redraw function seems to be broken - added example on generating responsive plots. From 4481d950293cdeea27f5be67f04bcd43f90b493d Mon Sep 17 00:00:00 2001 From: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com> Date: Tue, 31 Dec 2024 13:53:15 +0100 Subject: [PATCH 2/3] implement deserialize to NamedColor, Rgb, Rgba - remove prefix test_ from all unittest function names Fixes #264 Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com> --- CHANGELOG.md | 2 +- plotly/src/common/color.rs | 292 ++++++++++++++++++++++++++-- plotly/src/common/mod.rs | 104 +++++----- plotly/src/configuration.rs | 14 +- plotly/src/layout/mod.rs | 138 ++++++------- plotly/src/layout/themes.rs | 6 +- plotly/src/layout/update_menu.rs | 6 +- plotly/src/plot.rs | 46 ++--- plotly/src/private.rs | 8 +- plotly/src/traces/bar.rs | 4 +- plotly/src/traces/box_plot.rs | 14 +- plotly/src/traces/candlestick.rs | 4 +- plotly/src/traces/contour.rs | 16 +- plotly/src/traces/density_mapbox.rs | 2 +- plotly/src/traces/heat_map.rs | 8 +- plotly/src/traces/histogram.rs | 20 +- plotly/src/traces/image.rs | 8 +- plotly/src/traces/mesh3d.rs | 12 +- plotly/src/traces/ohlc.rs | 4 +- plotly/src/traces/sankey.rs | 14 +- plotly/src/traces/scatter.rs | 8 +- plotly/src/traces/scatter3d.rs | 10 +- plotly/src/traces/scatter_mapbox.rs | 6 +- plotly/src/traces/scatter_polar.rs | 4 +- plotly/src/traces/surface.rs | 14 +- plotly/src/traces/table.rs | 2 +- plotly_kaleido/src/lib.rs | 16 +- 27 files changed, 524 insertions(+), 258 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bb499e5b..515f0e01 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## [0.12.0] - 2024-12-31 +## [0.12.0] - 2025-01-02 ### Changed - [[#256](https://github.com/plotly/plotly.rs/pull/256)] Bump Cargo.toml edition to 2021 - [[#261](https://github.com/plotly/plotly.rs/pull/261)] Updated code of conduct diff --git a/plotly/src/common/color.rs b/plotly/src/common/color.rs index e03e0ee2..238712b8 100644 --- a/plotly/src/common/color.rs +++ b/plotly/src/common/color.rs @@ -1,3 +1,8 @@ +use std::error::Error; +use std::fmt; +use std::num::{ParseFloatError, ParseIntError}; +use std::str::FromStr; + /// This module provides several user interfaces for describing a color to be /// used throughout the rest of the library. The easiest way of describing a /// colour is to use a `&str` or `String`, which is simply serialized as-is and @@ -19,7 +24,7 @@ /// [`predefined colors`]: use dyn_clone::DynClone; use erased_serde::Serialize as ErasedSerialize; -use serde::Serialize; +use serde::{de, Deserialize, Deserializer, Serialize}; /// A marker trait allowing several ways to describe a color. pub trait Color: DynClone + ErasedSerialize + Send + Sync + std::fmt::Debug + 'static {} @@ -61,7 +66,7 @@ impl Into>> for ColorArray { /// A type-safe way of constructing a valid RGB color from constituent R, G and /// B channels. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, Eq, PartialEq)] pub struct Rgb { pub(crate) r: u8, pub(crate) g: u8, @@ -84,9 +89,74 @@ impl Serialize for Rgb { } } +#[derive(Debug, PartialEq, Eq)] +pub struct ParseError { + msg: String, +} + +impl ParseError { + fn new(msg: &str) -> ParseError { + ParseError { + msg: msg.to_string(), + } + } +} + +impl fmt::Display for ParseError { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.msg) + } +} + +impl Error for ParseError { + fn description(&self) -> &str { + &self.msg + } +} + +impl From for ParseError { + fn from(err: ParseIntError) -> ParseError { + ParseError::new(err.to_string().as_str()) + } +} + +impl From for ParseError { + fn from(err: ParseFloatError) -> ParseError { + ParseError::new(err.to_string().as_str()) + } +} + +impl FromStr for Rgb { + type Err = ParseError; + fn from_str(rgb: &str) -> std::result::Result { + let prefix: &[_] = &['r', 'g', 'b', 'a', '(']; + let trimmed = rgb.trim_start_matches(prefix).trim_end_matches(')'); + let fields: Vec<&str> = trimmed.split(',').collect(); + if fields.len() != 3 { + Err(ParseError::new("Invalid string length of for RGB color")) + } else { + Ok(Rgb { + r: u8::from_str(fields[0].trim())?, + g: u8::from_str(fields[1].trim())?, + b: u8::from_str(fields[2].trim())?, + }) + } + } +} + +impl<'de> Deserialize<'de> for Rgb { + fn deserialize(deserializer: D) -> std::result::Result + where + D: Deserializer<'de>, + { + let s = String::deserialize(deserializer)?; + FromStr::from_str(&s).map_err(de::Error::custom) + } +} + /// A type-safe way of constructing a valid RGBA color from constituent R, G, B /// and A channels. -#[derive(Debug, Clone, Copy)] +#[derive(Debug, Clone, Copy, PartialEq)] pub struct Rgba { pub(crate) r: u8, pub(crate) g: u8, @@ -113,10 +183,41 @@ impl Serialize for Rgba { } } +impl FromStr for Rgba { + type Err = ParseError; + fn from_str(rgba: &str) -> std::result::Result { + let prefix: &[_] = &['r', 'g', 'b', 'a', '(']; + let trimmed = rgba.trim_start_matches(prefix).trim_end_matches(')'); + let fields: Vec<&str> = trimmed.split(',').collect(); + dbg!(&fields); + println!("{:?}", &fields); + if fields.len() != 4 { + Err(ParseError::new("Invalid string length of for RGBA color")) + } else { + Ok(Rgba { + r: u8::from_str(fields[0].trim())?, + g: u8::from_str(fields[1].trim())?, + b: u8::from_str(fields[2].trim())?, + a: f64::from_str(fields[3].trim())?, + }) + } + } +} + +impl<'de> Deserialize<'de> for Rgba { + fn deserialize(deserializer: D) -> std::result::Result + where + D: Deserializer<'de>, + { + let s = String::deserialize(deserializer)?; + FromStr::from_str(&s).map_err(de::Error::custom) + } +} + /// Cross-browser compatible [`predefined colors`]. /// /// [`predefined colors`]: -#[derive(Debug, Clone, Copy, Serialize)] +#[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] #[serde(rename_all = "lowercase")] pub enum NamedColor { AliceBlue, @@ -272,36 +373,50 @@ pub enum NamedColor { #[cfg(test)] mod tests { - use serde_json::{json, to_value}; + use serde_json::{from_value, json, to_value}; use super::*; #[test] - fn test_serialize_rgb() { + fn serialize_rgb() { let rgb = Rgb::new(80, 90, 100); assert_eq!(to_value(rgb).unwrap(), json!("rgb(80, 90, 100)")); } #[test] - fn test_serialize_rgba() { - let rgb = Rgba::new(80, 90, 100, 0.2); - assert_eq!(to_value(rgb).unwrap(), json!("rgba(80, 90, 100, 0.2)")); + fn deserialize_rgb() { + let rgb = json!("rgb(80, 90, 100)"); + let expected = Rgb::new(80, 90, 100); + assert_eq!(from_value::(rgb).unwrap(), expected); + } + + #[test] + fn serialize_rgba() { + let rgba = Rgba::new(80, 90, 100, 0.2); + assert_eq!(to_value(rgba).unwrap(), json!("rgba(80, 90, 100, 0.2)")); } #[test] - fn test_serialize_str() { + fn deserialize_rgba() { + let rgba = json!("rgba(80, 90, 100, 0.2)"); + let expected = Rgba::new(80, 90, 100, 0.2); + assert_eq!(from_value::(rgba).unwrap(), expected); + } + + #[test] + fn serialize_str() { let color = "any_arbitrary_string"; assert_eq!(to_value(color).unwrap(), json!("any_arbitrary_string")); } #[test] - fn test_serialize_string() { + fn serialize_string() { let color = "any_arbitrary_string".to_string(); assert_eq!(to_value(color).unwrap(), json!("any_arbitrary_string")); } #[test] - fn test_serialize_numbers() { + fn serialize_numbers() { assert_eq!(to_value(1f64).unwrap(), json!(1f64)); assert_eq!(to_value(1f32).unwrap(), json!(1f32)); assert_eq!(to_value(1i64).unwrap(), json!(1i64)); @@ -316,7 +431,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_named_color() { + fn serialize_named_color() { assert_eq!(to_value(NamedColor::AliceBlue).unwrap(), json!("aliceblue")); assert_eq!(to_value(NamedColor::AntiqueWhite).unwrap(), json!("antiquewhite")); assert_eq!(to_value(NamedColor::Aqua).unwrap(), json!("aqua")); @@ -464,4 +579,155 @@ mod tests { assert_eq!(to_value(NamedColor::YellowGreen).unwrap(), json!("yellowgreen")); assert_eq!(to_value(NamedColor::Transparent).unwrap(), json!("transparent")); } + + #[test] + #[rustfmt::skip] + fn deserialize_named_color() { + assert_eq!(from_value::(json!("aliceblue")).unwrap(), NamedColor::AliceBlue); + assert_eq!(from_value::(json!("antiquewhite")).unwrap(),NamedColor::AntiqueWhite); + assert_eq!(from_value::(json!("aqua")).unwrap(),NamedColor::Aqua); + assert_eq!(from_value::(json!("aquamarine")).unwrap(),NamedColor::Aquamarine); + assert_eq!(from_value::(json!("azure")).unwrap(),NamedColor::Azure); + assert_eq!(from_value::(json!("beige")).unwrap(),NamedColor::Beige); + assert_eq!(from_value::(json!("bisque")).unwrap(),NamedColor::Bisque); + assert_eq!(from_value::(json!("black")).unwrap(),NamedColor::Black); + assert_eq!(from_value::(json!("blanchedalmond")).unwrap(),NamedColor::BlanchedAlmond); + assert_eq!(from_value::(json!("blue")).unwrap(),NamedColor::Blue); + assert_eq!(from_value::(json!("blueviolet")).unwrap(),NamedColor::BlueViolet); + assert_eq!(from_value::(json!("brown")).unwrap(),NamedColor::Brown); + assert_eq!(from_value::(json!("burlywood")).unwrap(),NamedColor::BurlyWood); + assert_eq!(from_value::(json!("cadetblue")).unwrap(),NamedColor::CadetBlue); + assert_eq!(from_value::(json!("chartreuse")).unwrap(),NamedColor::Chartreuse); + assert_eq!(from_value::(json!("chocolate")).unwrap(),NamedColor::Chocolate); + assert_eq!(from_value::(json!("coral")).unwrap(),NamedColor::Coral); + assert_eq!(from_value::(json!("cornflowerblue")).unwrap(),NamedColor::CornflowerBlue); + assert_eq!(from_value::(json!("cornsilk")).unwrap(),NamedColor::CornSilk); + assert_eq!(from_value::(json!("crimson")).unwrap(),NamedColor::Crimson); + assert_eq!(from_value::(json!("cyan")).unwrap(),NamedColor::Cyan); + assert_eq!(from_value::(json!("darkblue")).unwrap(),NamedColor::DarkBlue); + assert_eq!(from_value::(json!("darkcyan")).unwrap(),NamedColor::DarkCyan); + assert_eq!(from_value::(json!("darkgoldenrod")).unwrap(),NamedColor::DarkGoldenrod); + assert_eq!(from_value::(json!("darkgray")).unwrap(),NamedColor::DarkGray); + assert_eq!(from_value::(json!("darkgrey")).unwrap(),NamedColor::DarkGrey); + assert_eq!(from_value::(json!("darkgreen")).unwrap(),NamedColor::DarkGreen); + assert_eq!(from_value::(json!("darkorange")).unwrap(),NamedColor::DarkOrange); + assert_eq!(from_value::(json!("darkorchid")).unwrap(),NamedColor::DarkOrchid); + assert_eq!(from_value::(json!("darkred")).unwrap(),NamedColor::DarkRed); + assert_eq!(from_value::(json!("darksalmon")).unwrap(),NamedColor::DarkSalmon); + assert_eq!(from_value::(json!("darkseagreen")).unwrap(),NamedColor::DarkSeaGreen); + assert_eq!(from_value::(json!("darkslateblue")).unwrap(),NamedColor::DarkSlateBlue); + assert_eq!(from_value::(json!("darkslategray")).unwrap(),NamedColor::DarkSlateGray); + assert_eq!(from_value::(json!("darkslategrey")).unwrap(),NamedColor::DarkSlateGrey); + assert_eq!(from_value::(json!("darkturquoise")).unwrap(),NamedColor::DarkTurquoise); + assert_eq!(from_value::(json!("darkviolet")).unwrap(),NamedColor::DarkViolet); + assert_eq!(from_value::(json!("deeppink")).unwrap(),NamedColor::DeepPink); + assert_eq!(from_value::(json!("deepskyblue")).unwrap(),NamedColor::DeepSkyBlue); + assert_eq!(from_value::(json!("dimgray")).unwrap(),NamedColor::DimGray); + assert_eq!(from_value::(json!("dimgrey")).unwrap(),NamedColor::DimGrey); + assert_eq!(from_value::(json!("dodgerblue")).unwrap(),NamedColor::DodgerBlue); + assert_eq!(from_value::(json!("firebrick")).unwrap(),NamedColor::FireBrick); + assert_eq!(from_value::(json!("floralwhite")).unwrap(),NamedColor::FloralWhite); + assert_eq!(from_value::(json!("forestgreen")).unwrap(),NamedColor::ForestGreen); + assert_eq!(from_value::(json!("fuchsia")).unwrap(),NamedColor::Fuchsia); + assert_eq!(from_value::(json!("gainsboro")).unwrap(),NamedColor::Gainsboro); + assert_eq!(from_value::(json!("ghostwhite")).unwrap(),NamedColor::GhostWhite); + assert_eq!(from_value::(json!("gold")).unwrap(),NamedColor::Gold); + assert_eq!(from_value::(json!("goldenrod")).unwrap(),NamedColor::Goldenrod); + assert_eq!(from_value::(json!("gray")).unwrap(),NamedColor::Gray); + assert_eq!(from_value::(json!("grey")).unwrap(),NamedColor::Grey); + assert_eq!(from_value::(json!("green")).unwrap(),NamedColor::Green); + assert_eq!(from_value::(json!("greenyellow")).unwrap(),NamedColor::GreenYellow); + assert_eq!(from_value::(json!("honeydew")).unwrap(),NamedColor::Honeydew); + assert_eq!(from_value::(json!("hotpink")).unwrap(),NamedColor::HotPink); + assert_eq!(from_value::(json!("indianred")).unwrap(),NamedColor::IndianRed); + assert_eq!(from_value::(json!("indigo")).unwrap(),NamedColor::Indigo); + assert_eq!(from_value::(json!("ivory")).unwrap(),NamedColor::Ivory); + assert_eq!(from_value::(json!("khaki")).unwrap(),NamedColor::Khaki); + assert_eq!(from_value::(json!("lavender")).unwrap(),NamedColor::Lavender); + assert_eq!(from_value::(json!("lavenderblush")).unwrap(),NamedColor::LavenderBlush); + assert_eq!(from_value::(json!("lawngreen")).unwrap(),NamedColor::LawnGreen); + assert_eq!(from_value::(json!("lemonchiffon")).unwrap(),NamedColor::LemonChiffon); + assert_eq!(from_value::(json!("lightblue")).unwrap(),NamedColor::LightBlue); + assert_eq!(from_value::(json!("lightcoral")).unwrap(),NamedColor::LightCoral); + assert_eq!(from_value::(json!("lightcyan")).unwrap(),NamedColor::LightCyan); + assert_eq!(from_value::(json!("lightgoldenrodyellow")).unwrap(),NamedColor::LightGoldenrodYellow); + assert_eq!(from_value::(json!("lightgray")).unwrap(),NamedColor::LightGray); + assert_eq!(from_value::(json!("lightgrey")).unwrap(),NamedColor::LightGrey); + assert_eq!(from_value::(json!("lightgreen")).unwrap(),NamedColor::LightGreen); + assert_eq!(from_value::(json!("lightpink")).unwrap(),NamedColor::LightPink); + assert_eq!(from_value::(json!("lightsalmon")).unwrap(),NamedColor::LightSalmon); + assert_eq!(from_value::(json!("lightseagreen")).unwrap(),NamedColor::LightSeaGreen); + assert_eq!(from_value::(json!("lightskyblue")).unwrap(),NamedColor::LightSkyBlue); + assert_eq!(from_value::(json!("lightslategray")).unwrap(),NamedColor::LightSlateGray); + assert_eq!(from_value::(json!("lightslategrey")).unwrap(),NamedColor::LightSlateGrey); + assert_eq!(from_value::(json!("lightsteelblue")).unwrap(),NamedColor::LightSteelBlue); + assert_eq!(from_value::(json!("lightyellow")).unwrap(),NamedColor::LightYellow); + assert_eq!(from_value::(json!("lime")).unwrap(),NamedColor::Lime); + assert_eq!(from_value::(json!("limegreen")).unwrap(),NamedColor::LimeGreen); + assert_eq!(from_value::(json!("linen")).unwrap(),NamedColor::Linen); + assert_eq!(from_value::(json!("magenta")).unwrap(),NamedColor::Magenta); + assert_eq!(from_value::(json!("maroon")).unwrap(),NamedColor::Maroon); + assert_eq!(from_value::(json!("mediumaquamarine")).unwrap(),NamedColor::MediumAquamarine); + assert_eq!(from_value::(json!("mediumblue")).unwrap(),NamedColor::MediumBlue); + assert_eq!(from_value::(json!("mediumorchid")).unwrap(),NamedColor::MediumOrchid); + assert_eq!(from_value::(json!("mediumpurple")).unwrap(),NamedColor::MediumPurple); + assert_eq!(from_value::(json!("mediumseagreen")).unwrap(),NamedColor::MediumSeaGreen); + assert_eq!(from_value::(json!("mediumslateblue")).unwrap(),NamedColor::MediumSlateBlue); + assert_eq!(from_value::(json!("mediumspringgreen")).unwrap(),NamedColor::MediumSpringGreen); + assert_eq!(from_value::(json!("mediumturquoise")).unwrap(),NamedColor::MediumTurquoise); + assert_eq!(from_value::(json!("mediumvioletred")).unwrap(),NamedColor::MediumVioletRed); + assert_eq!(from_value::(json!("midnightblue")).unwrap(),NamedColor::MidnightBlue); + assert_eq!(from_value::(json!("mintcream")).unwrap(),NamedColor::MintCream); + assert_eq!(from_value::(json!("mistyrose")).unwrap(),NamedColor::MistyRose); + assert_eq!(from_value::(json!("moccasin")).unwrap(),NamedColor::Moccasin); + assert_eq!(from_value::(json!("navajowhite")).unwrap(),NamedColor::NavajoWhite); + assert_eq!(from_value::(json!("navy")).unwrap(),NamedColor::Navy); + assert_eq!(from_value::(json!("oldlace")).unwrap(),NamedColor::OldLace); + assert_eq!(from_value::(json!("olive")).unwrap(),NamedColor::Olive); + assert_eq!(from_value::(json!("olivedrab")).unwrap(),NamedColor::OliveDrab); + assert_eq!(from_value::(json!("orange")).unwrap(),NamedColor::Orange); + assert_eq!(from_value::(json!("orangered")).unwrap(),NamedColor::OrangeRed); + assert_eq!(from_value::(json!("orchid")).unwrap(),NamedColor::Orchid); + assert_eq!(from_value::(json!("palegoldenrod")).unwrap(),NamedColor::PaleGoldenrod); + assert_eq!(from_value::(json!("palegreen")).unwrap(),NamedColor::PaleGreen); + assert_eq!(from_value::(json!("paleturquoise")).unwrap(),NamedColor::PaleTurquoise); + assert_eq!(from_value::(json!("palevioletred")).unwrap(),NamedColor::PaleVioletRed); + assert_eq!(from_value::(json!("papayawhip")).unwrap(),NamedColor::PapayaWhip); + assert_eq!(from_value::(json!("peachpuff")).unwrap(),NamedColor::PeachPuff); + assert_eq!(from_value::(json!("peru")).unwrap(),NamedColor::Peru); + assert_eq!(from_value::(json!("pink")).unwrap(),NamedColor::Pink); + assert_eq!(from_value::(json!("plum")).unwrap(),NamedColor::Plum); + assert_eq!(from_value::(json!("powderblue")).unwrap(),NamedColor::PowderBlue); + assert_eq!(from_value::(json!("purple")).unwrap(),NamedColor::Purple); + assert_eq!(from_value::(json!("rebeccapurple")).unwrap(),NamedColor::RebeccaPurple); + assert_eq!(from_value::(json!("red")).unwrap(),NamedColor::Red); + assert_eq!(from_value::(json!("rosybrown")).unwrap(),NamedColor::RosyBrown); + assert_eq!(from_value::(json!("royalblue")).unwrap(),NamedColor::RoyalBlue); + assert_eq!(from_value::(json!("saddlebrown")).unwrap(),NamedColor::SaddleBrown); + assert_eq!(from_value::(json!("salmon")).unwrap(),NamedColor::Salmon); + assert_eq!(from_value::(json!("sandybrown")).unwrap(),NamedColor::SandyBrown); + assert_eq!(from_value::(json!("seagreen")).unwrap(),NamedColor::SeaGreen); + assert_eq!(from_value::(json!("seashell")).unwrap(),NamedColor::Seashell); + assert_eq!(from_value::(json!("sienna")).unwrap(),NamedColor::Sienna); + assert_eq!(from_value::(json!("silver")).unwrap(),NamedColor::Silver); + assert_eq!(from_value::(json!("skyblue")).unwrap(),NamedColor::SkyBlue); + assert_eq!(from_value::(json!("slateblue")).unwrap(),NamedColor::SlateBlue); + assert_eq!(from_value::(json!("slategray")).unwrap(),NamedColor::SlateGray); + assert_eq!(from_value::(json!("slategrey")).unwrap(),NamedColor::SlateGrey); + assert_eq!(from_value::(json!("snow")).unwrap(),NamedColor::Snow); + assert_eq!(from_value::(json!("springgreen")).unwrap(),NamedColor::SpringGreen); + assert_eq!(from_value::(json!("steelblue")).unwrap(),NamedColor::SteelBlue); + assert_eq!(from_value::(json!("tan")).unwrap(),NamedColor::Tan); + assert_eq!(from_value::(json!("teal")).unwrap(),NamedColor::Teal); + assert_eq!(from_value::(json!("thistle")).unwrap(),NamedColor::Thistle); + assert_eq!(from_value::(json!("tomato")).unwrap(),NamedColor::Tomato); + assert_eq!(from_value::(json!("turquoise")).unwrap(),NamedColor::Turquoise); + assert_eq!(from_value::(json!("violet")).unwrap(),NamedColor::Violet); + assert_eq!(from_value::(json!("wheat")).unwrap(),NamedColor::Wheat); + assert_eq!(from_value::(json!("white")).unwrap(),NamedColor::White); + assert_eq!(from_value::(json!("whitesmoke")).unwrap(),NamedColor::WhiteSmoke); + assert_eq!(from_value::(json!("yellow")).unwrap(),NamedColor::Yellow); + assert_eq!(from_value::(json!("yellowgreen")).unwrap(),NamedColor::YellowGreen); + assert_eq!(from_value::(json!("transparent")).unwrap(),NamedColor::Transparent); + } } diff --git a/plotly/src/common/mod.rs b/plotly/src/common/mod.rs index 81b5d551..7816a41a 100644 --- a/plotly/src/common/mod.rs +++ b/plotly/src/common/mod.rs @@ -1643,7 +1643,7 @@ mod tests { use crate::color::NamedColor; #[test] - fn test_serialize_domain() { + fn serialize_domain() { let domain = Domain::new().column(0).row(0).x(&[0., 1.]).y(&[0., 1.]); let expected = json!({ "column": 0, @@ -1656,7 +1656,7 @@ mod tests { } #[test] - fn test_serialize_direction() { + fn serialize_direction() { // TODO: I think `Direction` would be better as a struct, with `fillcolor` and // `line` attributes let inc = Direction::Increasing { line: Line::new() }; @@ -1669,7 +1669,7 @@ mod tests { } #[test] - fn test_serialize_hover_info() { + fn serialize_hover_info() { assert_eq!(to_value(HoverInfo::X).unwrap(), json!("x")); assert_eq!(to_value(HoverInfo::Y).unwrap(), json!("y")); assert_eq!(to_value(HoverInfo::Z).unwrap(), json!("z")); @@ -1685,7 +1685,7 @@ mod tests { } #[test] - fn test_serialize_text_position() { + fn serialize_text_position() { assert_eq!(to_value(TextPosition::Inside).unwrap(), json!("inside")); assert_eq!(to_value(TextPosition::Outside).unwrap(), json!("outside")); assert_eq!(to_value(TextPosition::Auto).unwrap(), json!("auto")); @@ -1693,7 +1693,7 @@ mod tests { } #[test] - fn test_serialize_constrain_text() { + fn serialize_constrain_text() { assert_eq!(to_value(ConstrainText::Inside).unwrap(), json!("inside")); assert_eq!(to_value(ConstrainText::Outside).unwrap(), json!("outside")); assert_eq!(to_value(ConstrainText::Both).unwrap(), json!("both")); @@ -1702,13 +1702,13 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_orientation() { + fn serialize_orientation() { assert_eq!(to_value(Orientation::Vertical).unwrap(), json!("v")); assert_eq!(to_value(Orientation::Horizontal).unwrap(), json!("h")); } #[test] - fn test_serialize_fill() { + fn serialize_fill() { assert_eq!(to_value(Fill::ToZeroY).unwrap(), json!("tozeroy")); assert_eq!(to_value(Fill::ToZeroX).unwrap(), json!("tozerox")); assert_eq!(to_value(Fill::ToNextY).unwrap(), json!("tonexty")); @@ -1719,7 +1719,7 @@ mod tests { } #[test] - fn test_serialize_calendar() { + fn serialize_calendar() { assert_eq!(to_value(Calendar::Gregorian).unwrap(), json!("gregorian")); assert_eq!(to_value(Calendar::Chinese).unwrap(), json!("chinese")); assert_eq!(to_value(Calendar::Coptic).unwrap(), json!("coptic")); @@ -1739,14 +1739,14 @@ mod tests { } #[test] - fn test_serialize_dim() { + fn serialize_dim() { assert_eq!(to_value(Dim::Scalar(0)).unwrap(), json!(0)); assert_eq!(to_value(Dim::Vector(vec![0])).unwrap(), json!([0])); } #[test] #[rustfmt::skip] - fn test_serialize_plot_type() { + fn serialize_plot_type() { assert_eq!(to_value(PlotType::Scatter).unwrap(), json!("scatter")); assert_eq!(to_value(PlotType::ScatterGL).unwrap(), json!("scattergl")); assert_eq!(to_value(PlotType::Scatter3D).unwrap(), json!("scatter3d")); @@ -1766,7 +1766,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_mode() { + fn serialize_mode() { assert_eq!(to_value(Mode::Lines).unwrap(), json!("lines")); assert_eq!(to_value(Mode::Markers).unwrap(), json!("markers")); assert_eq!(to_value(Mode::Text).unwrap(), json!("text")); @@ -1779,7 +1779,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_axis_side() { + fn serialize_axis_side() { assert_eq!(to_value(AxisSide::Left).unwrap(), json!("left")); assert_eq!(to_value(AxisSide::Top).unwrap(), json!("top")); assert_eq!(to_value(AxisSide::Right).unwrap(), json!("right")); @@ -1788,7 +1788,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_position() { + fn serialize_position() { assert_eq!(to_value(Position::TopLeft).unwrap(), json!("top left")); assert_eq!(to_value(Position::TopCenter).unwrap(), json!("top center")); assert_eq!(to_value(Position::TopRight).unwrap(), json!("top right")); @@ -1801,14 +1801,14 @@ mod tests { } #[test] - fn test_serialize_ticks() { + fn serialize_ticks() { assert_eq!(to_value(Ticks::Outside).unwrap(), json!("outside")); assert_eq!(to_value(Ticks::Inside).unwrap(), json!("inside")); assert_eq!(to_value(Ticks::None).unwrap(), json!("")); } #[test] - fn test_serialize_show() { + fn serialize_show() { assert_eq!(to_value(Show::All).unwrap(), json!("all")); assert_eq!(to_value(Show::First).unwrap(), json!("first")); assert_eq!(to_value(Show::Last).unwrap(), json!("last")); @@ -1816,7 +1816,7 @@ mod tests { } #[test] - fn test_serialize_default_color_bar() { + fn serialize_default_color_bar() { let color_bar = ColorBar::new(); let expected = json!({}); @@ -1824,7 +1824,7 @@ mod tests { } #[test] - fn test_serialize_color_bar() { + fn serialize_color_bar() { let color_bar = ColorBar::new() .background_color("#123456") .border_color("#123456") @@ -1913,7 +1913,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_marker_symbol() { + fn serialize_marker_symbol() { assert_eq!(to_value(MarkerSymbol::Circle).unwrap(), json!("circle")); assert_eq!(to_value(MarkerSymbol::CircleOpen).unwrap(), json!("circle-open")); assert_eq!(to_value(MarkerSymbol::CircleDot).unwrap(), json!("circle-dot")); @@ -2059,7 +2059,7 @@ mod tests { } #[test] - fn test_serialize_tick_mode() { + fn serialize_tick_mode() { assert_eq!(to_value(TickMode::Auto).unwrap(), json!("auto")); assert_eq!(to_value(TickMode::Linear).unwrap(), json!("linear")); assert_eq!(to_value(TickMode::Array).unwrap(), json!("array")); @@ -2067,7 +2067,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_dash_type() { + fn serialize_dash_type() { assert_eq!(to_value(DashType::Solid).unwrap(), json!("solid")); assert_eq!(to_value(DashType::Dot).unwrap(), json!("dot")); assert_eq!(to_value(DashType::Dash).unwrap(), json!("dash")); @@ -2078,13 +2078,13 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_color_scale_element() { + fn serialize_color_scale_element() { assert_eq!(to_value(ColorScaleElement(0., "red".to_string())).unwrap(), json!([0.0, "red"])); } #[test] #[rustfmt::skip] - fn test_serialize_color_scale_palette() { + fn serialize_color_scale_palette() { assert_eq!(to_value(ColorScalePalette::Greys).unwrap(), json!("Greys")); assert_eq!(to_value(ColorScalePalette::YlGnBu).unwrap(), json!("YlGnBu")); assert_eq!(to_value(ColorScalePalette::Greens).unwrap(), json!("Greens")); @@ -2106,7 +2106,7 @@ mod tests { } #[test] - fn test_serialize_color_scale() { + fn serialize_color_scale() { assert_eq!( to_value(ColorScale::Palette(ColorScalePalette::Greys)).unwrap(), json!("Greys") @@ -2122,7 +2122,7 @@ mod tests { } #[test] - fn test_serialize_line_shape() { + fn serialize_line_shape() { assert_eq!(to_value(LineShape::Linear).unwrap(), json!("linear")); assert_eq!(to_value(LineShape::Spline).unwrap(), json!("spline")); assert_eq!(to_value(LineShape::Hv).unwrap(), json!("hv")); @@ -2132,7 +2132,7 @@ mod tests { } #[test] - fn test_serialize_line() { + fn serialize_line() { let line = Line::new() .width(0.1) .shape(LineShape::Linear) @@ -2173,7 +2173,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_gradient_type() { + fn serialize_gradient_type() { assert_eq!(to_value(GradientType::Radial).unwrap(), json!("radial")); assert_eq!(to_value(GradientType::Horizontal).unwrap(), json!("horizontal")); assert_eq!(to_value(GradientType::Vertical).unwrap(), json!("vertical")); @@ -2181,20 +2181,20 @@ mod tests { } #[test] - fn test_serialize_size_mode() { + fn serialize_size_mode() { assert_eq!(to_value(SizeMode::Diameter).unwrap(), json!("diameter")); assert_eq!(to_value(SizeMode::Area).unwrap(), json!("area")); } #[test] #[rustfmt::skip] - fn test_serialize_thickness_mode() { + fn serialize_thickness_mode() { assert_eq!(to_value(ThicknessMode::Fraction).unwrap(), json!("fraction")); assert_eq!(to_value(ThicknessMode::Pixels).unwrap(), json!("pixels")); } #[test] - fn test_serialize_anchor() { + fn serialize_anchor() { assert_eq!(to_value(Anchor::Auto).unwrap(), json!("auto")); assert_eq!(to_value(Anchor::Left).unwrap(), json!("left")); assert_eq!(to_value(Anchor::Center).unwrap(), json!("center")); @@ -2205,14 +2205,14 @@ mod tests { } #[test] - fn test_serialize_text_anchor() { + fn serialize_text_anchor() { assert_eq!(to_value(TextAnchor::Start).unwrap(), json!("start")); assert_eq!(to_value(TextAnchor::Middle).unwrap(), json!("middle")); assert_eq!(to_value(TextAnchor::End).unwrap(), json!("end")); } #[test] - fn test_serialize_exponent_format() { + fn serialize_exponent_format() { assert_eq!(to_value(ExponentFormat::None).unwrap(), json!("none")); assert_eq!(to_value(ExponentFormat::SmallE).unwrap(), json!("e")); assert_eq!(to_value(ExponentFormat::CapitalE).unwrap(), json!("E")); @@ -2223,7 +2223,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_gradient() { + fn serialize_gradient() { let gradient = Gradient::new(GradientType::Horizontal, "#ffffff"); let expected = json!({"color": "#ffffff", "type": "horizontal"}); assert_eq!(to_value(gradient).unwrap(), expected); @@ -2234,14 +2234,14 @@ mod tests { } #[test] - fn test_serialize_tick_format_stop_default() { + fn serialize_tick_format_stop_default() { let tick_format_stop = TickFormatStop::new(); let expected = json!({"enabled": true}); assert_eq!(to_value(tick_format_stop).unwrap(), expected); } #[test] - fn test_serialize_tick_format_stop() { + fn serialize_tick_format_stop() { let tick_format_stop = TickFormatStop::new() .enabled(false) .dtick_range(vec![0.0, 1.0]) @@ -2259,7 +2259,7 @@ mod tests { } #[test] - fn test_serialize_pattern_shape() { + fn serialize_pattern_shape() { assert_eq!(to_value(PatternShape::None).unwrap(), json!("")); assert_eq!(to_value(PatternShape::HorizonalLine).unwrap(), json!("-")); assert_eq!(to_value(PatternShape::VerticalLine).unwrap(), json!("|")); @@ -2277,7 +2277,7 @@ mod tests { } #[test] - fn test_serialize_pattern_fill_mode() { + fn serialize_pattern_fill_mode() { assert_eq!( to_value(PatternFillMode::Replace).unwrap(), json!("replace") @@ -2289,7 +2289,7 @@ mod tests { } #[test] - fn test_serialize_pattern() { + fn serialize_pattern() { let pattern = Pattern::new() .shape_array(vec![ PatternShape::HorizonalLine, @@ -2316,7 +2316,7 @@ mod tests { } #[test] - fn test_serialize_marker() { + fn serialize_marker() { let marker = Marker::new() .symbol(MarkerSymbol::Circle) .opacity(0.1) @@ -2378,7 +2378,7 @@ mod tests { } #[test] - fn test_serialize_font() { + fn serialize_font() { let font = Font::new().family("family").size(100).color("#FFFFFF"); let expected = json!({ "family": "family", @@ -2390,7 +2390,7 @@ mod tests { } #[test] - fn test_serialize_side() { + fn serialize_side() { assert_eq!(to_value(Side::Right).unwrap(), json!("right")); assert_eq!(to_value(Side::Top).unwrap(), json!("top")); assert_eq!(to_value(Side::Bottom).unwrap(), json!("bottom")); @@ -2399,14 +2399,14 @@ mod tests { } #[test] - fn test_serialize_reference() { + fn serialize_reference() { assert_eq!(to_value(Reference::Container).unwrap(), json!("container")); assert_eq!(to_value(Reference::Paper).unwrap(), json!("paper")); } #[test] #[rustfmt::skip] - fn test_serialize_legend_group_title() { + fn serialize_legend_group_title() { assert_eq!(to_value(LegendGroupTitle::new()).unwrap(), json!({})); assert_eq!(to_value(LegendGroupTitle::with_text("title_str").font(Font::default())).unwrap(), json!({"font": {}, "text": "title_str"})); assert_eq!(to_value(LegendGroupTitle::from(String::from("title_string"))).unwrap(), json!({"text" : "title_string"})); @@ -2414,7 +2414,7 @@ mod tests { } #[test] - fn test_serialize_pad() { + fn serialize_pad() { let pad = Pad::new(1, 2, 3); let expected = json!({ "t": 1, @@ -2426,7 +2426,7 @@ mod tests { } #[test] - fn test_serialize_title() { + fn serialize_title() { let title = Title::with_text("title") .font(Font::new()) .side(Side::Top) @@ -2454,7 +2454,7 @@ mod tests { } #[test] - fn test_serialize_title_from_str() { + fn serialize_title_from_str() { let title = Title::from("from"); let expected = json!({"text": "from"}); @@ -2467,7 +2467,7 @@ mod tests { } #[test] - fn test_serialize_label() { + fn serialize_label() { let label = Label::new() .background_color("#FFFFFF") .border_color("#000000") @@ -2487,7 +2487,7 @@ mod tests { } #[test] - fn test_serialize_error_type() { + fn serialize_error_type() { assert_eq!(to_value(ErrorType::Percent).unwrap(), json!("percent")); assert_eq!(to_value(ErrorType::Constant).unwrap(), json!("constant")); assert_eq!(to_value(ErrorType::SquareRoot).unwrap(), json!("sqrt")); @@ -2495,12 +2495,12 @@ mod tests { } #[test] - fn test_serialize_error_type_default() { + fn serialize_error_type_default() { assert_eq!(to_value(ErrorType::default()).unwrap(), json!("percent")); } #[test] - fn test_serialize_error_data() { + fn serialize_error_data() { let error_data = ErrorData::new(ErrorType::Constant) .array(vec![0.1, 0.2]) .visible(true) @@ -2534,7 +2534,7 @@ mod tests { } #[test] - fn test_serialize_visible() { + fn serialize_visible() { assert_eq!(to_value(Visible::True).unwrap(), json!(true)); assert_eq!(to_value(Visible::False).unwrap(), json!(false)); assert_eq!(to_value(Visible::LegendOnly).unwrap(), json!("legendonly")); @@ -2542,7 +2542,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_hover_on() { + fn serialize_hover_on() { assert_eq!(to_value(HoverOn::Points).unwrap(), json!("points")); assert_eq!(to_value(HoverOn::Fills).unwrap(), json!("fills")); assert_eq!(to_value(HoverOn::PointsAndFills).unwrap(), json!("points+fills")); @@ -2551,7 +2551,7 @@ mod tests { #[test] #[allow(clippy::needless_borrows_for_generic_args)] - fn test_title_method_can_take_string() { + fn title_method_can_take_string() { ColorBar::new().title("Title"); ColorBar::new().title(String::from("Title")); ColorBar::new().title(&String::from("Title")); diff --git a/plotly/src/configuration.rs b/plotly/src/configuration.rs index 36c9c8ce..ae8c9352 100644 --- a/plotly/src/configuration.rs +++ b/plotly/src/configuration.rs @@ -437,14 +437,14 @@ mod tests { use super::*; #[test] - fn test_serialize_image_button_formats() { + fn serialize_image_button_formats() { assert_eq!(to_value(ImageButtonFormats::Png).unwrap(), json!("png")); assert_eq!(to_value(ImageButtonFormats::Svg).unwrap(), json!("svg")); assert_eq!(to_value(ImageButtonFormats::Jpeg).unwrap(), json!("jpeg")); assert_eq!(to_value(ImageButtonFormats::Webp).unwrap(), json!("webp")); } #[test] - fn test_serialize_to_image_button_options() { + fn serialize_to_image_button_options() { let options = ToImageButtonOptions::new() .format(ImageButtonFormats::Jpeg) .filename("filename") @@ -463,7 +463,7 @@ mod tests { } #[test] - fn test_serialize_display_mode_bar() { + fn serialize_display_mode_bar() { assert_eq!(to_value(DisplayModeBar::Hover).unwrap(), json!("hover")); assert_eq!(to_value(DisplayModeBar::True).unwrap(), json!(true)); assert_eq!(to_value(DisplayModeBar::False).unwrap(), json!(false)); @@ -471,7 +471,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_mode_bar_button_name() { + fn serialize_mode_bar_button_name() { assert_eq!(to_value(ModeBarButtonName::Zoom2d).unwrap(), json!("zoom2d")); assert_eq!(to_value(ModeBarButtonName::Pan2d).unwrap(), json!("pan2d")); assert_eq!(to_value(ModeBarButtonName::Select2d).unwrap(), json!("select2d")); @@ -507,7 +507,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_double_click() { + fn serialize_double_click() { assert_eq!(to_value(DoubleClick::False).unwrap(), json!(false)); assert_eq!(to_value(DoubleClick::Reset).unwrap(), json!("reset")); assert_eq!(to_value(DoubleClick::AutoSize).unwrap(), json!("autosize")); @@ -515,7 +515,7 @@ mod tests { } #[test] - fn test_serialize_plot_gl_pixel_ratio() { + fn serialize_plot_gl_pixel_ratio() { assert_eq!(to_value(PlotGLPixelRatio::One).unwrap(), json!(1)); assert_eq!(to_value(PlotGLPixelRatio::Two).unwrap(), json!(2)); assert_eq!(to_value(PlotGLPixelRatio::Three).unwrap(), json!(3)); @@ -523,7 +523,7 @@ mod tests { } #[test] - fn test_serialize_configuration() { + fn serialize_configuration() { let config = Configuration::new() .static_plot(true) .typeset_math(true) diff --git a/plotly/src/layout/mod.rs b/plotly/src/layout/mod.rs index af3eabf6..57d33184 100644 --- a/plotly/src/layout/mod.rs +++ b/plotly/src/layout/mod.rs @@ -2081,21 +2081,21 @@ mod tests { use crate::common::ColorScalePalette; #[test] - fn test_serialize_uniform_text_mode() { + fn serialize_uniform_text_mode() { assert_eq!(to_value(UniformTextMode::False).unwrap(), json!(false)); assert_eq!(to_value(UniformTextMode::Hide).unwrap(), json!("hide")); assert_eq!(to_value(UniformTextMode::Show).unwrap(), json!("show")); } #[test] - fn test_serialize_click_to_show() { + fn serialize_click_to_show() { assert_eq!(to_value(ClickToShow::False).unwrap(), json!(false)); assert_eq!(to_value(ClickToShow::OnOff).unwrap(), json!("onoff")); assert_eq!(to_value(ClickToShow::OnOut).unwrap(), json!("onout")); } #[test] - fn test_serialize_hover_mode() { + fn serialize_hover_mode() { assert_eq!(to_value(HoverMode::X).unwrap(), json!("x")); assert_eq!(to_value(HoverMode::Y).unwrap(), json!("y")); assert_eq!(to_value(HoverMode::Closest).unwrap(), json!("closest")); @@ -2106,7 +2106,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_axis_type() { + fn serialize_axis_type() { assert_eq!(to_value(AxisType::Default).unwrap(), json!("-")); assert_eq!(to_value(AxisType::Linear).unwrap(), json!("linear")); assert_eq!(to_value(AxisType::Log).unwrap(), json!("log")); @@ -2116,14 +2116,14 @@ mod tests { } #[test] - fn test_serialize_axis_constrain() { + fn serialize_axis_constrain() { assert_eq!(to_value(AxisConstrain::Range).unwrap(), json!("range")); assert_eq!(to_value(AxisConstrain::Domain).unwrap(), json!("domain")); } #[test] #[rustfmt::skip] - fn test_serialize_constrain_direction() { + fn serialize_constrain_direction() { assert_eq!(to_value(ConstrainDirection::Left).unwrap(), json!("left")); assert_eq!(to_value(ConstrainDirection::Center).unwrap(), json!("center")); assert_eq!(to_value(ConstrainDirection::Right).unwrap(), json!("right")); @@ -2134,27 +2134,27 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_range_mode() { + fn serialize_range_mode() { assert_eq!(to_value(RangeMode::Normal).unwrap(), json!("normal")); assert_eq!(to_value(RangeMode::ToZero).unwrap(), json!("tozero")); assert_eq!(to_value(RangeMode::NonNegative).unwrap(), json!("nonnegative")); } #[test] - fn test_serialize_ticks_direction() { + fn serialize_ticks_direction() { assert_eq!(to_value(TicksDirection::Outside).unwrap(), json!("outside")); assert_eq!(to_value(TicksDirection::Inside).unwrap(), json!("inside")); } #[test] #[rustfmt::skip] - fn test_serialize_ticks_position() { + fn serialize_ticks_position() { assert_eq!(to_value(TicksPosition::Labels).unwrap(), json!("labels")); assert_eq!(to_value(TicksPosition::Boundaries).unwrap(), json!("boundaries")); } #[test] - fn test_serialize_array_show() { + fn serialize_array_show() { assert_eq!(to_value(ArrayShow::All).unwrap(), json!("all")); assert_eq!(to_value(ArrayShow::First).unwrap(), json!("first")); assert_eq!(to_value(ArrayShow::Last).unwrap(), json!("last")); @@ -2162,7 +2162,7 @@ mod tests { } #[test] - fn test_serialize_bar_mode() { + fn serialize_bar_mode() { assert_eq!(to_value(BarMode::Stack).unwrap(), json!("stack")); assert_eq!(to_value(BarMode::Group).unwrap(), json!("group")); assert_eq!(to_value(BarMode::Overlay).unwrap(), json!("overlay")); @@ -2170,33 +2170,33 @@ mod tests { } #[test] - fn test_serialize_bar_norm() { + fn serialize_bar_norm() { assert_eq!(to_value(BarNorm::Empty).unwrap(), json!("")); assert_eq!(to_value(BarNorm::Fraction).unwrap(), json!("fraction")); assert_eq!(to_value(BarNorm::Percent).unwrap(), json!("percent")); } #[test] - fn test_serialize_box_mode() { + fn serialize_box_mode() { assert_eq!(to_value(BoxMode::Group).unwrap(), json!("group")); assert_eq!(to_value(BoxMode::Overlay).unwrap(), json!("overlay")); } #[test] - fn test_serialize_violin_mode() { + fn serialize_violin_mode() { assert_eq!(to_value(ViolinMode::Group).unwrap(), json!("group")); assert_eq!(to_value(ViolinMode::Overlay).unwrap(), json!("overlay")); } #[test] - fn test_serialize_waterfall_mode() { + fn serialize_waterfall_mode() { assert_eq!(to_value(WaterfallMode::Group).unwrap(), json!("group")); assert_eq!(to_value(WaterfallMode::Overlay).unwrap(), json!("overlay")); } #[test] #[rustfmt::skip] - fn test_serialize_trace_order() { + fn serialize_trace_order() { assert_eq!(to_value(TraceOrder::Reversed).unwrap(), json!("reversed")); assert_eq!(to_value(TraceOrder::Grouped).unwrap(), json!("grouped")); assert_eq!(to_value(TraceOrder::ReversedGrouped).unwrap(), json!("reversed+grouped")); @@ -2204,14 +2204,14 @@ mod tests { } #[test] - fn test_serialize_item_sizing() { + fn serialize_item_sizing() { assert_eq!(to_value(ItemSizing::Trace).unwrap(), json!("trace")); assert_eq!(to_value(ItemSizing::Constant).unwrap(), json!("constant")); } #[test] #[rustfmt::skip] - fn test_serialize_item_click() { + fn serialize_item_click() { assert_eq!(to_value(ItemClick::Toggle).unwrap(), json!("toggle")); assert_eq!(to_value(ItemClick::ToggleOthers).unwrap(), json!("toggleothers")); assert_eq!(to_value(ItemClick::False).unwrap(), json!(false)); @@ -2219,13 +2219,13 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_group_click() { + fn serialize_group_click() { assert_eq!(to_value(GroupClick::ToggleItem).unwrap(), json!("toggleitem")); assert_eq!(to_value(GroupClick::ToggleGroup).unwrap(), json!("togglegroup")); } #[test] - fn test_serialize_legend() { + fn serialize_legend() { let legend = Legend::new() .background_color("#123123") .border_color("#321321") @@ -2271,21 +2271,21 @@ mod tests { } #[test] - fn test_serialize_valign() { + fn serialize_valign() { assert_eq!(to_value(VAlign::Top).unwrap(), json!("top")); assert_eq!(to_value(VAlign::Middle).unwrap(), json!("middle")); assert_eq!(to_value(VAlign::Bottom).unwrap(), json!("bottom")); } #[test] - fn test_serialize_halign() { + fn serialize_halign() { assert_eq!(to_value(HAlign::Left).unwrap(), json!("left")); assert_eq!(to_value(HAlign::Center).unwrap(), json!("center")); assert_eq!(to_value(HAlign::Right).unwrap(), json!("right")); } #[test] - fn test_serialize_margin() { + fn serialize_margin() { let margin = Margin::new() .left(1) .right(2) @@ -2306,7 +2306,7 @@ mod tests { } #[test] - fn test_serialize_layout_color_scale() { + fn serialize_layout_color_scale() { let layout_color_scale = LayoutColorScale::new() .sequential(ColorScale::Palette(ColorScalePalette::Greys)) .sequential_minus(ColorScale::Palette(ColorScalePalette::Blues)) @@ -2321,14 +2321,14 @@ mod tests { } #[test] - fn test_serialize_slider_range_mode() { + fn serialize_slider_range_mode() { assert_eq!(to_value(SliderRangeMode::Auto).unwrap(), json!("auto")); assert_eq!(to_value(SliderRangeMode::Fixed).unwrap(), json!("fixed")); assert_eq!(to_value(SliderRangeMode::Match).unwrap(), json!("match")); } #[test] - fn test_serialize_range_slider_y_axis() { + fn serialize_range_slider_y_axis() { let range_slider_y_axis = RangeSliderYAxis::new() .range_mode(SliderRangeMode::Match) .range(vec![0.2]); @@ -2341,7 +2341,7 @@ mod tests { } #[test] - fn test_serialize_range_slider() { + fn serialize_range_slider() { let range_slider = RangeSlider::new() .background_color("#123ABC") .border_color("#ABC123") @@ -2367,7 +2367,7 @@ mod tests { } #[test] - fn test_serialize_selector_step() { + fn serialize_selector_step() { assert_eq!(to_value(SelectorStep::Month).unwrap(), json!("month")); assert_eq!(to_value(SelectorStep::Year).unwrap(), json!("year")); assert_eq!(to_value(SelectorStep::Day).unwrap(), json!("day")); @@ -2378,14 +2378,14 @@ mod tests { } #[test] - fn test_serialize_step_mode() { + fn serialize_step_mode() { assert_eq!(to_value(StepMode::Backward).unwrap(), json!("backward")); assert_eq!(to_value(StepMode::ToDate).unwrap(), json!("todate")); } #[test] #[rustfmt::skip] - fn test_serialize_spike_mode() { + fn serialize_spike_mode() { assert_eq!(to_value(SpikeMode::ToAxis).unwrap(), json!("toaxis")); assert_eq!(to_value(SpikeMode::Across).unwrap(), json!("across")); assert_eq!(to_value(SpikeMode::Marker).unwrap(), json!("marker")); @@ -2397,7 +2397,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_spike_snap() { + fn serialize_spike_snap() { assert_eq!(to_value(SpikeSnap::Data).unwrap(), json!("data")); assert_eq!(to_value(SpikeSnap::Cursor).unwrap(), json!("cursor")); assert_eq!(to_value(SpikeSnap::HoveredData).unwrap(), json!("hovered data")); @@ -2405,7 +2405,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_category_order() { + fn serialize_category_order() { assert_eq!(to_value(CategoryOrder::Trace).unwrap(), json!("trace")); assert_eq!(to_value(CategoryOrder::CategoryAscending).unwrap(), json!("category ascending")); assert_eq!(to_value(CategoryOrder::CategoryDescending).unwrap(), json!("category descending")); @@ -2427,7 +2427,7 @@ mod tests { } #[test] - fn test_serialize_selector_button() { + fn serialize_selector_button() { let selector_button = SelectorButton::new() .visible(false) .step(SelectorStep::Hour) @@ -2451,7 +2451,7 @@ mod tests { } #[test] - fn test_serialize_range_selector() { + fn serialize_range_selector() { let range_selector = RangeSelector::new() .visible(true) .buttons(vec![SelectorButton::new()]) @@ -2483,7 +2483,7 @@ mod tests { } #[test] - fn test_serialize_color_axis() { + fn serialize_color_axis() { let color_axis = ColorAxis::new() .auto_color_scale(false) .cauto(true) @@ -2511,7 +2511,7 @@ mod tests { } #[test] - fn test_serialize_axis() { + fn serialize_axis() { let axis = Axis::new() .visible(false) .color("#678123") @@ -2652,21 +2652,21 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_row_order() { + fn serialize_row_order() { assert_eq!(to_value(RowOrder::TopToBottom).unwrap(), json!("top to bottom")); assert_eq!(to_value(RowOrder::BottomToTop).unwrap(), json!("bottom to top")); } #[test] #[rustfmt::skip] - fn test_serialize_grid_pattern() { + fn serialize_grid_pattern() { assert_eq!(to_value(GridPattern::Independent).unwrap(), json!("independent")); assert_eq!(to_value(GridPattern::Coupled).unwrap(), json!("coupled")); } #[test] #[rustfmt::skip] - fn test_serialize_grid_x_side() { + fn serialize_grid_x_side() { assert_eq!(to_value(GridXSide::Bottom).unwrap(), json!("bottom")); assert_eq!(to_value(GridXSide::BottomPlot).unwrap(), json!("bottom plot")); assert_eq!(to_value(GridXSide::Top).unwrap(), json!("top")); @@ -2675,7 +2675,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_grid_y_side() { + fn serialize_grid_y_side() { assert_eq!(to_value(GridYSide::Left).unwrap(), json!("left")); assert_eq!(to_value(GridYSide::LeftPlot).unwrap(), json!("left plot")); assert_eq!(to_value(GridYSide::Right).unwrap(), json!("right")); @@ -2683,7 +2683,7 @@ mod tests { } #[test] - fn test_serialize_grid_domain() { + fn serialize_grid_domain() { let grid_domain = GridDomain::new().x(vec![0.0]).y(vec![1.0]); let expected = json!({ "x": [0.0], @@ -2694,7 +2694,7 @@ mod tests { } #[test] - fn test_serialize_layout_grid() { + fn serialize_layout_grid() { let layout_grid = LayoutGrid::new() .rows(224) .row_order(RowOrder::BottomToTop) @@ -2728,7 +2728,7 @@ mod tests { } #[test] - fn test_serialize_uniform_text() { + fn serialize_uniform_text() { let uniform_text = UniformText::new().mode(UniformTextMode::Hide).min_size(5); let expected = json!({ "mode": "hide", @@ -2739,7 +2739,7 @@ mod tests { } #[test] - fn test_serialize_mode_bar() { + fn serialize_mode_bar() { let mode_bar = ModeBar::new() .orientation(Orientation::Horizontal) .background_color("#FFF000") @@ -2756,7 +2756,7 @@ mod tests { } #[test] - fn test_serialize_shape_type() { + fn serialize_shape_type() { assert_eq!(to_value(ShapeType::Circle).unwrap(), json!("circle")); assert_eq!(to_value(ShapeType::Rect).unwrap(), json!("rect")); assert_eq!(to_value(ShapeType::Path).unwrap(), json!("path")); @@ -2764,25 +2764,25 @@ mod tests { } #[test] - fn test_serialize_shape_layer() { + fn serialize_shape_layer() { assert_eq!(to_value(ShapeLayer::Below).unwrap(), json!("below")); assert_eq!(to_value(ShapeLayer::Above).unwrap(), json!("above")); } #[test] - fn test_serialize_shape_size_mode() { + fn serialize_shape_size_mode() { assert_eq!(to_value(ShapeSizeMode::Scaled).unwrap(), json!("scaled")); assert_eq!(to_value(ShapeSizeMode::Pixel).unwrap(), json!("pixel")); } #[test] - fn test_serialize_fill_rule() { + fn serialize_fill_rule() { assert_eq!(to_value(FillRule::EvenOdd).unwrap(), json!("evenodd")); assert_eq!(to_value(FillRule::NonZero).unwrap(), json!("nonzero")); } #[test] - fn test_serialize_shape_line() { + fn serialize_shape_line() { let shape_line = ShapeLine::new() .color("#000FFF") .width(100.) @@ -2797,7 +2797,7 @@ mod tests { } #[test] - fn test_serialize_shape() { + fn serialize_shape() { let shape = Shape::new() .visible(false) .shape_type(ShapeType::Circle) @@ -2850,7 +2850,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_draw_direction() { + fn serialize_draw_direction() { assert_eq!(to_value(DrawDirection::Ortho).unwrap(), json!("ortho")); assert_eq!(to_value(DrawDirection::Horizontal).unwrap(), json!("horizontal")); assert_eq!(to_value(DrawDirection::Vertical).unwrap(), json!("vertical")); @@ -2858,7 +2858,7 @@ mod tests { } #[test] - fn test_serialize_new_shape() { + fn serialize_new_shape() { let new_shape = NewShape::new() .line(ShapeLine::new()) .fill_color("#123ABC") @@ -2880,7 +2880,7 @@ mod tests { } #[test] - fn test_serialize_active_shape() { + fn serialize_active_shape() { let active_shape = ActiveShape::new().fill_color("#123ABC").opacity(0.02); let expected = json!({ @@ -2892,7 +2892,7 @@ mod tests { } #[test] - fn test_serialize_arrow_side() { + fn serialize_arrow_side() { assert_eq!(to_value(ArrowSide::End).unwrap(), json!("end")); assert_eq!(to_value(ArrowSide::Start).unwrap(), json!("start")); assert_eq!(to_value(ArrowSide::StartEnd).unwrap(), json!("end+start")); @@ -2900,7 +2900,7 @@ mod tests { } #[test] - fn test_serialize_annotation() { + fn serialize_annotation() { let annotation = Annotation::new() .align(HAlign::Center) .arrow_color("#464646") @@ -2997,7 +2997,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_click_mode() { + fn serialize_click_mode() { assert_eq!(to_value(ClickMode::Event).unwrap(), json!("event")); assert_eq!(to_value(ClickMode::Select).unwrap(), json!("select")); assert_eq!(to_value(ClickMode::EventAndSelect).unwrap(), json!("event+select")); @@ -3006,7 +3006,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_drag_mode() { + fn serialize_drag_mode() { assert_eq!(to_value(DragMode::Zoom).unwrap(), json!("zoom")); assert_eq!(to_value(DragMode::Pan).unwrap(), json!("pan")); assert_eq!(to_value(DragMode::Select).unwrap(), json!("select")); @@ -3023,7 +3023,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_mapbox_style() { + fn serialize_mapbox_style() { assert_eq!(to_value(MapboxStyle::CartoDarkMatter).unwrap(), json!("carto-darkmatter")); assert_eq!(to_value(MapboxStyle::CartoPositron).unwrap(), json!("carto-positron")); assert_eq!(to_value(MapboxStyle::OpenStreetMap).unwrap(), json!("open-street-map")); @@ -3041,7 +3041,7 @@ mod tests { } #[test] - fn test_serialize_select_direction() { + fn serialize_select_direction() { assert_eq!(to_value(SelectDirection::Horizontal).unwrap(), json!("h")); assert_eq!(to_value(SelectDirection::Vertical).unwrap(), json!("v")); assert_eq!(to_value(SelectDirection::Diagonal).unwrap(), json!("d")); @@ -3049,7 +3049,7 @@ mod tests { } #[test] - fn test_serialize_layout_template() { + fn serialize_layout_template() { let layout_template = LayoutTemplate::new() .title("Title") .show_legend(false) @@ -3183,7 +3183,7 @@ mod tests { } #[test] - fn test_serialize_template() { + fn serialize_template() { let template = Template::new().layout(LayoutTemplate::new()); let expected = json!({"layout": {}}); @@ -3191,7 +3191,7 @@ mod tests { } #[test] - fn test_serialize_layout() { + fn serialize_layout() { let layout = Layout::new() .title("Title") .title(String::from("Title")) @@ -3333,7 +3333,7 @@ mod tests { } #[test] - fn test_serialize_layout_scene() { + fn serialize_layout_scene() { let layout = Layout::new().scene( LayoutScene::new() .x_axis(Axis::new()) @@ -3365,7 +3365,7 @@ mod tests { } #[test] - fn test_serialize_eye() { + fn serialize_eye() { let eye = Eye::new(); assert_eq!( @@ -3393,7 +3393,7 @@ mod tests { } #[test] - fn test_serialize_projection() { + fn serialize_projection() { let projection = Projection::new().projection_type(ProjectionType::default()); let expected = json!({ @@ -3416,7 +3416,7 @@ mod tests { } #[test] - fn test_serialize_camera_center() { + fn serialize_camera_center() { let camera_center = CameraCenter::new(); let expected = json!({ @@ -3443,7 +3443,7 @@ mod tests { } #[test] - fn test_serialize_aspect_ratio() { + fn serialize_aspect_ratio() { let aspect_ratio = AspectRatio::new(); let expected = json!({ @@ -3470,7 +3470,7 @@ mod tests { } #[test] - fn test_serialize_aspect_mode() { + fn serialize_aspect_mode() { let aspect_mode = AspectMode::default(); assert_eq!(to_value(aspect_mode).unwrap(), json!("auto")); @@ -3485,7 +3485,7 @@ mod tests { } #[test] - fn test_serialize_up() { + fn serialize_up() { let up = Up::new(); let expected = json!({ diff --git a/plotly/src/layout/themes.rs b/plotly/src/layout/themes.rs index a687caa7..6d010295 100644 --- a/plotly/src/layout/themes.rs +++ b/plotly/src/layout/themes.rs @@ -166,7 +166,7 @@ mod tests { use crate::*; #[test] - fn test_plotly_default() { + fn plotly_default() { let template = &*DEFAULT; let layout = Layout::new().template(template); let mut plot = Plot::new(); @@ -178,7 +178,7 @@ mod tests { } #[test] - fn test_plotly_white() { + fn plotly_white() { let template = &*PLOTLY_WHITE; let layout = Layout::new().template(template); let mut plot = Plot::new(); @@ -191,7 +191,7 @@ mod tests { } #[test] - fn test_plotly_dark() { + fn plotly_dark() { let template = &*PLOTLY_DARK; let layout = Layout::new().template(template); let mut plot = Plot::new(); diff --git a/plotly/src/layout/update_menu.rs b/plotly/src/layout/update_menu.rs index f662a7f2..855161b0 100644 --- a/plotly/src/layout/update_menu.rs +++ b/plotly/src/layout/update_menu.rs @@ -249,7 +249,7 @@ mod tests { use crate::{common::Visible, Layout}; #[test] - fn test_serialize_button_method() { + fn serialize_button_method() { assert_eq!(to_value(ButtonMethod::Restyle).unwrap(), json!("restyle")); assert_eq!(to_value(ButtonMethod::Relayout).unwrap(), json!("relayout")); assert_eq!(to_value(ButtonMethod::Animate).unwrap(), json!("animate")); @@ -258,7 +258,7 @@ mod tests { } #[test] - fn test_serialize_button() { + fn serialize_button() { let button = Button::new() .args(json!([ { "visible": [true, false] }, @@ -290,7 +290,7 @@ mod tests { } #[test] - fn test_button_builder() { + fn button_builder() { let expected = json!({ "args": [ { "visible": [true, false] }, diff --git a/plotly/src/plot.rs b/plotly/src/plot.rs index f6213dd2..6dbe22eb 100644 --- a/plotly/src/plot.rs +++ b/plotly/src/plot.rs @@ -600,7 +600,7 @@ mod tests { } #[test] - fn test_inline_plot() { + fn inline_plot() { let plot = create_test_plot(); let inline_plot_data = plot.to_inline_html(Some("replace_this_with_the_div_id")); assert!(inline_plot_data.contains("replace_this_with_the_div_id")); @@ -608,25 +608,25 @@ mod tests { } #[test] - fn test_jupyter_notebook_plot() { + fn jupyter_notebook_plot() { let plot = create_test_plot(); plot.to_jupyter_notebook_html(); } #[test] - fn test_notebook_display() { + fn notebook_display() { let plot = create_test_plot(); plot.notebook_display(); } #[test] - fn test_lab_display() { + fn lab_display() { let plot = create_test_plot(); plot.lab_display(); } #[test] - fn test_plot_serialize_simple() { + fn plot_serialize_simple() { let plot = create_test_plot(); let expected = json!({ "data": [ @@ -645,7 +645,7 @@ mod tests { } #[test] - fn test_plot_serialize_with_layout() { + fn plot_serialize_with_layout() { let mut plot = create_test_plot(); let layout = Layout::new().title("Title"); plot.set_layout(layout); @@ -671,7 +671,7 @@ mod tests { } #[test] - fn test_data_to_json() { + fn data_to_json() { let plot = create_test_plot(); let expected = json!([ { @@ -686,7 +686,7 @@ mod tests { } #[test] - fn test_empty_layout_to_json() { + fn empty_layout_to_json() { let plot = create_test_plot(); let expected = json!({}); @@ -694,7 +694,7 @@ mod tests { } #[test] - fn test_layout_to_json() { + fn layout_to_json() { let mut plot = create_test_plot(); let layout = Layout::new().title("TestTitle"); plot.set_layout(layout); @@ -707,7 +707,7 @@ mod tests { } #[test] - fn test_plot_eq() { + fn plot_eq() { let plot1 = create_test_plot(); let plot2 = create_test_plot(); @@ -715,7 +715,7 @@ mod tests { } #[test] - fn test_plot_neq() { + fn plot_neq() { let plot1 = create_test_plot(); let trace2 = Scatter::new(vec![10, 1, 2], vec![6, 10, 2]).name("trace2"); let mut plot2 = Plot::new(); @@ -725,7 +725,7 @@ mod tests { } #[test] - fn test_plot_clone() { + fn plot_clone() { let plot1 = create_test_plot(); let plot2 = plot1.clone(); @@ -735,13 +735,13 @@ mod tests { #[test] #[ignore] // Don't really want it to try and open a browser window every time we run a test. #[cfg(not(feature = "wasm"))] - fn test_show_image() { + fn show_image() { let plot = create_test_plot(); plot.show_image(ImageFormat::PNG, 1024, 680); } #[test] - fn test_save_html() { + fn save_html() { let plot = create_test_plot(); let dst = PathBuf::from("example.html"); plot.write_html(&dst); @@ -753,7 +753,7 @@ mod tests { #[cfg(not(target_os = "macos"))] #[test] #[cfg(feature = "kaleido")] - fn test_save_to_png() { + fn save_to_png() { let plot = create_test_plot(); let dst = PathBuf::from("example.png"); plot.write_image(&dst, ImageFormat::PNG, 1024, 680, 1.0); @@ -765,7 +765,7 @@ mod tests { #[cfg(not(target_os = "macos"))] #[test] #[cfg(feature = "kaleido")] - fn test_save_to_jpeg() { + fn save_to_jpeg() { let plot = create_test_plot(); let dst = PathBuf::from("example.jpeg"); plot.write_image(&dst, ImageFormat::JPEG, 1024, 680, 1.0); @@ -777,7 +777,7 @@ mod tests { #[cfg(not(target_os = "macos"))] #[test] #[cfg(feature = "kaleido")] - fn test_save_to_svg() { + fn save_to_svg() { let plot = create_test_plot(); let dst = PathBuf::from("example.svg"); plot.write_image(&dst, ImageFormat::SVG, 1024, 680, 1.0); @@ -789,7 +789,7 @@ mod tests { #[test] #[ignore] // This seems to fail unpredictably on MacOs. #[cfg(feature = "kaleido")] - fn test_save_to_eps() { + fn save_to_eps() { let plot = create_test_plot(); let dst = PathBuf::from("example.eps"); plot.write_image(&dst, ImageFormat::EPS, 1024, 680, 1.0); @@ -801,7 +801,7 @@ mod tests { #[cfg(not(target_os = "macos"))] #[test] #[cfg(feature = "kaleido")] - fn test_save_to_pdf() { + fn save_to_pdf() { let plot = create_test_plot(); let dst = PathBuf::from("example.pdf"); plot.write_image(&dst, ImageFormat::PDF, 1024, 680, 1.0); @@ -813,7 +813,7 @@ mod tests { #[cfg(not(target_os = "macos"))] #[test] #[cfg(feature = "kaleido")] - fn test_save_to_webp() { + fn save_to_webp() { let plot = create_test_plot(); let dst = PathBuf::from("example.webp"); plot.write_image(&dst, ImageFormat::WEBP, 1024, 680, 1.0); @@ -825,7 +825,7 @@ mod tests { #[test] #[cfg(not(target_os = "macos"))] #[cfg(feature = "kaleido")] - fn test_image_to_base64() { + fn image_to_base64() { let plot = create_test_plot(); let image_base64 = plot.to_base64(ImageFormat::PNG, 200, 150, 1.0); @@ -844,7 +844,7 @@ mod tests { #[test] #[cfg(feature = "kaleido")] - fn test_image_to_base64_invalid_format() { + fn image_to_base64_invalid_format() { let plot = create_test_plot(); let image_base64 = plot.to_base64(ImageFormat::EPS, 200, 150, 1.0); assert!(image_base64.is_empty()); @@ -853,7 +853,7 @@ mod tests { #[test] #[cfg(not(target_os = "macos"))] #[cfg(feature = "kaleido")] - fn test_image_to_svg_string() { + fn image_to_svg_string() { let plot = create_test_plot(); let image_svg = plot.to_svg(200, 150, 1.0); diff --git a/plotly/src/private.rs b/plotly/src/private.rs index 76e3f3b4..4a4b0967 100644 --- a/plotly/src/private.rs +++ b/plotly/src/private.rs @@ -132,7 +132,7 @@ mod tests { use super::*; #[test] - fn test_num_or_string() { + fn num_or_string() { let x: NumOrString = "String".to_string().into(); assert_eq!(x, NumOrString::S("String".to_string())); @@ -168,7 +168,7 @@ mod tests { } #[test] - fn test_num_or_string_collection() { + fn num_or_string_collection() { let x: NumOrStringCollection = vec!["&str"].into(); let expected = NumOrStringCollection(vec![NumOrString::S("&str".to_string())]); assert_eq!(x, expected); @@ -188,7 +188,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_num_or_string() { + fn serialize_num_or_string() { assert_eq!(to_value(NumOrString::S("&str".to_string())).unwrap(), json!("&str")); assert_eq!(to_value(NumOrString::F(100.)).unwrap(), json!(100.0)); assert_eq!(to_value(NumOrString::I(-50)).unwrap(), json!(-50)); @@ -197,7 +197,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_num_or_string_collection() { + fn serialize_num_or_string_collection() { assert_eq!(to_value(NumOrStringCollection(vec![NumOrString::S("&str".to_string())])).unwrap(), json!(["&str"])); assert_eq!(to_value(NumOrStringCollection(vec![NumOrString::F(100.)])).unwrap(), json!([100.0])); assert_eq!(to_value(NumOrStringCollection(vec![NumOrString::I(-50)])).unwrap(), json!([-50])); diff --git a/plotly/src/traces/bar.rs b/plotly/src/traces/bar.rs index 92ccc0b5..01d70527 100644 --- a/plotly/src/traces/bar.rs +++ b/plotly/src/traces/bar.rs @@ -134,7 +134,7 @@ mod tests { use crate::common::ErrorType; #[test] - fn test_default_bar() { + fn default_bar() { let trace: Bar = Bar::default(); let expected = json!({"type": "bar"}).to_string(); @@ -142,7 +142,7 @@ mod tests { } #[test] - fn test_serialize_bar() { + fn serialize_bar() { let bar = Bar::new(vec![1, 2], vec![3, 4]) .alignment_group("alignment_group") .clip_on_axis(true) diff --git a/plotly/src/traces/box_plot.rs b/plotly/src/traces/box_plot.rs index 8903c480..604eb1d3 100644 --- a/plotly/src/traces/box_plot.rs +++ b/plotly/src/traces/box_plot.rs @@ -215,7 +215,7 @@ mod tests { use super::*; #[test] - fn test_serialize_box_mean() { + fn serialize_box_mean() { assert_eq!(to_value(BoxMean::True).unwrap(), json!(true)); assert_eq!(to_value(BoxMean::False).unwrap(), json!(false)); assert_eq!(to_value(BoxMean::StandardDeviation).unwrap(), json!("sd")); @@ -223,7 +223,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_box_points() { + fn serialize_box_points() { assert_eq!(to_value(BoxPoints::All).unwrap(), json!("all")); assert_eq!(to_value(BoxPoints::Outliers).unwrap(), json!("outliers")); assert_eq!(to_value(BoxPoints::SuspectedOutliers).unwrap(), json!("suspectedoutliers")); @@ -232,7 +232,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_quartile_method() { + fn serialize_quartile_method() { assert_eq!(to_value(QuartileMethod::Linear).unwrap(), json!("linear")); assert_eq!(to_value(QuartileMethod::Exclusive).unwrap(), json!("exclusive")); assert_eq!(to_value(QuartileMethod::Inclusive).unwrap(), json!("inclusive")); @@ -240,14 +240,14 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_hover_on() { + fn serialize_hover_on() { assert_eq!(to_value(HoverOn::Boxes).unwrap(), json!("boxes")); assert_eq!(to_value(HoverOn::Points).unwrap(), json!("points")); assert_eq!(to_value(HoverOn::BoxesAndPoints).unwrap(), json!("boxes+points")); } #[test] - fn test_default_box_plot() { + fn default_box_plot() { let trace: BoxPlot = BoxPlot::default(); let expected = json!({"type": "box"}).to_string(); @@ -255,7 +255,7 @@ mod tests { } #[test] - fn test_box_plot_new() { + fn box_plot_new() { let trace = BoxPlot::new(vec![0.0, 0.1]); let expected = json!({ "type": "box", @@ -266,7 +266,7 @@ mod tests { } #[test] - fn test_serialize_box_plot() { + fn serialize_box_plot() { let trace = BoxPlot::new_xy(vec![1, 2, 3], vec![4, 5, 6]) .alignment_group("alignment_group") .box_mean(BoxMean::StandardDeviation) diff --git a/plotly/src/traces/candlestick.rs b/plotly/src/traces/candlestick.rs index 64b25a5b..9eaacce4 100644 --- a/plotly/src/traces/candlestick.rs +++ b/plotly/src/traces/candlestick.rs @@ -124,7 +124,7 @@ mod tests { use super::*; #[test] - fn test_default_candlestick() { + fn default_candlestick() { let trace: Candlestick = Candlestick::default(); let expected = json!({"type": "candlestick"}).to_string(); @@ -132,7 +132,7 @@ mod tests { } #[test] - fn test_serialize_candlestick() { + fn serialize_candlestick() { let trace = Candlestick::new( vec!["2020-05-20", "2020-05-21"], vec![5, 6], diff --git a/plotly/src/traces/contour.rs b/plotly/src/traces/contour.rs index d599dcb1..359eaf37 100644 --- a/plotly/src/traces/contour.rs +++ b/plotly/src/traces/contour.rs @@ -484,13 +484,13 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_contours_type() { + fn serialize_contours_type() { assert_eq!(to_value(ContoursType::Levels).unwrap(), json!("levels")); assert_eq!(to_value(ContoursType::Constraint).unwrap(), json!("constraint")); } #[test] - fn test_serialize_coloring() { + fn serialize_coloring() { assert_eq!(to_value(Coloring::Fill).unwrap(), json!("fill")); assert_eq!(to_value(Coloring::HeatMap).unwrap(), json!("heatmap")); assert_eq!(to_value(Coloring::Lines).unwrap(), json!("lines")); @@ -499,7 +499,7 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_operation() { + fn serialize_operation() { assert_eq!(to_value(Operation::Equals).unwrap(), json!("=")); assert_eq!(to_value(Operation::LessThan).unwrap(), json!("<")); assert_eq!(to_value(Operation::LessThanOrEqual).unwrap(), json!("<=")); @@ -510,14 +510,14 @@ mod tests { } #[test] - fn test_serialize_default_contours() { + fn serialize_default_contours() { let contours = Contours::new(); let expected = json!({}); assert_eq!(to_value(contours).unwrap(), expected); } #[test] - fn test_serialize_contours() { + fn serialize_contours() { let contours = Contours::new() .type_(ContoursType::Levels) .start(0.0) @@ -549,7 +549,7 @@ mod tests { } #[test] - fn test_serialize_default_contour() { + fn serialize_default_contour() { let trace: Contour = Contour::default(); let expected = json!({"type": "contour"}).to_string(); @@ -557,7 +557,7 @@ mod tests { } #[test] - fn test_new_z_contour() { + fn new_z_contour() { let trace = Contour::new_z(vec![1.0]); let expected = json!({ "type": "contour", @@ -568,7 +568,7 @@ mod tests { } #[test] - fn test_serialize_contour() { + fn serialize_contour() { let trace = Contour::new(vec![0., 1.], vec![2., 3.], vec![4., 5.]) .auto_color_scale(true) .auto_contour(true) diff --git a/plotly/src/traces/density_mapbox.rs b/plotly/src/traces/density_mapbox.rs index dd66ce67..30dac55a 100644 --- a/plotly/src/traces/density_mapbox.rs +++ b/plotly/src/traces/density_mapbox.rs @@ -117,7 +117,7 @@ mod tests { use super::*; #[test] - fn test_serialize_density_mapbox() { + fn serialize_density_mapbox() { let density_mapbox = DensityMapbox::new(vec![45.5017], vec![-73.5673], vec![1.0]) .name("name") .visible(Visible::True) diff --git a/plotly/src/traces/heat_map.rs b/plotly/src/traces/heat_map.rs index 811dcfb6..0fdf85c8 100644 --- a/plotly/src/traces/heat_map.rs +++ b/plotly/src/traces/heat_map.rs @@ -163,14 +163,14 @@ mod tests { use crate::common::ColorScalePalette; #[test] - fn test_serialize_smoothing() { + fn serialize_smoothing() { assert_eq!(to_value(Smoothing::Fast).unwrap(), json!("fast")); assert_eq!(to_value(Smoothing::Best).unwrap(), json!("best")); assert_eq!(to_value(Smoothing::False).unwrap(), json!(false)); } #[test] - fn test_serialize_default_heat_map() { + fn serialize_default_heat_map() { let trace = HeatMap::::default(); let expected = json!({"type": "heatmap"}).to_string(); @@ -178,7 +178,7 @@ mod tests { } #[test] - fn test_serialize_heat_map_z() { + fn serialize_heat_map_z() { let trace = HeatMap::new_z(vec![vec![1.0]]); let expected = json!({ "type": "heatmap", @@ -189,7 +189,7 @@ mod tests { } #[test] - fn test_serialize_heat_map() { + fn serialize_heat_map() { let trace = HeatMap::new( vec![0.0, 1.0], vec![2.0, 3.0], diff --git a/plotly/src/traces/histogram.rs b/plotly/src/traces/histogram.rs index cd804623..7b83b884 100644 --- a/plotly/src/traces/histogram.rs +++ b/plotly/src/traces/histogram.rs @@ -299,7 +299,7 @@ mod tests { use crate::common::ErrorType; #[test] - fn test_serialize_bins() { + fn serialize_bins() { let bins = Bins::new(0.0, 10.0, 5.0); let expected = json!({ "start": 0.0, @@ -311,7 +311,7 @@ mod tests { } #[test] - fn test_serialize_cumulative() { + fn serialize_cumulative() { let cumulative = Cumulative::new() .enabled(true) .direction(HistDirection::Decreasing) @@ -327,7 +327,7 @@ mod tests { } #[test] - fn test_serialize_current_bin() { + fn serialize_current_bin() { assert_eq!(to_value(CurrentBin::Include).unwrap(), json!("include")); assert_eq!(to_value(CurrentBin::Exclude).unwrap(), json!("exclude")); assert_eq!(to_value(CurrentBin::Half).unwrap(), json!("half")); @@ -335,13 +335,13 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_hist_direction() { + fn serialize_hist_direction() { assert_eq!(to_value(HistDirection::Increasing).unwrap(), json!("increasing")); assert_eq!(to_value(HistDirection::Decreasing).unwrap(), json!("decreasing")); } #[test] - fn test_serialize_hist_func() { + fn serialize_hist_func() { assert_eq!(to_value(HistFunc::Count).unwrap(), json!("count")); assert_eq!(to_value(HistFunc::Sum).unwrap(), json!("sum")); assert_eq!(to_value(HistFunc::Average).unwrap(), json!("avg")); @@ -350,7 +350,7 @@ mod tests { } #[test] #[rustfmt::skip] - fn test_serialize_hist_norm() { + fn serialize_hist_norm() { assert_eq!(to_value(HistNorm::Default).unwrap(), json!("")); assert_eq!(to_value(HistNorm::Percent).unwrap(), json!("percent")); assert_eq!(to_value(HistNorm::Probability).unwrap(), json!("probability")); @@ -359,7 +359,7 @@ mod tests { } #[test] - fn test_serialize_default_histogram() { + fn serialize_default_histogram() { let trace = Histogram::::default(); let expected = json!({"type": "histogram"}); @@ -367,7 +367,7 @@ mod tests { } #[test] - fn test_serialize_new_xy_histogram() { + fn serialize_new_xy_histogram() { let trace = Histogram::new_xy(vec![0, 1, 2, 3], vec![4, 5, 6, 7]); let expected = json!({ "type": "histogram", @@ -379,7 +379,7 @@ mod tests { } #[test] - fn test_serialize_new_vertical_histogram() { + fn serialize_new_vertical_histogram() { let trace = Histogram::new_vertical(vec![0, 1, 2, 3]); let expected = json!({ "type": "histogram", @@ -390,7 +390,7 @@ mod tests { } #[test] - fn test_serialize_histogram() { + fn serialize_histogram() { let trace = Histogram::new(vec![0, 1, 2]) .alignment_group("alignmentgroup") .auto_bin_x(true) diff --git a/plotly/src/traces/image.rs b/plotly/src/traces/image.rs index 6c056f19..7fb4dd08 100644 --- a/plotly/src/traces/image.rs +++ b/plotly/src/traces/image.rs @@ -374,7 +374,7 @@ mod tests { use super::*; #[test] - fn test_serialize_pixel_color() { + fn serialize_pixel_color() { assert_eq!( to_value(PixelColor::Color3(255, 100, 150)).unwrap(), json!([255, 100, 150]) @@ -386,7 +386,7 @@ mod tests { } #[test] - fn test_serialize_color_model() { + fn serialize_color_model() { assert_eq!(to_value(ColorModel::RGB).unwrap(), json!("rgb")); assert_eq!(to_value(ColorModel::RGBA).unwrap(), json!("rgba")); assert_eq!(to_value(ColorModel::RGBA256).unwrap(), json!("rgba256")); @@ -395,13 +395,13 @@ mod tests { } #[test] - fn test_serialize_z_smooth() { + fn serialize_z_smooth() { assert_eq!(to_value(ZSmooth::Fast).unwrap(), json!("fast")); assert_eq!(to_value(ZSmooth::False).unwrap(), json!(false)); } #[test] - fn test_serialize_image() { + fn serialize_image() { let b = Rgba::new(0, 0, 0, 0.5); let w = Rgba::new(255, 255, 255, 1.0); let image = Image::new(vec![vec![b, w, b, w, b], vec![w, b, w, b, w]]) diff --git a/plotly/src/traces/mesh3d.rs b/plotly/src/traces/mesh3d.rs index c289e58f..152db20f 100644 --- a/plotly/src/traces/mesh3d.rs +++ b/plotly/src/traces/mesh3d.rs @@ -424,20 +424,20 @@ mod tests { use crate::common::ColorScalePalette; #[test] - fn test_serialize_intensity_mode() { + fn serialize_intensity_mode() { assert_eq!(to_value(IntensityMode::Vertex).unwrap(), json!("vertex")); assert_eq!(to_value(IntensityMode::Cell).unwrap(), json!("cell")); } #[test] - fn test_serialize_delaunay_axis() { + fn serialize_delaunay_axis() { assert_eq!(to_value(DelaunayAxis::X).unwrap(), json!("x")); assert_eq!(to_value(DelaunayAxis::Y).unwrap(), json!("y")); assert_eq!(to_value(DelaunayAxis::Z).unwrap(), json!("z")); } #[test] - fn test_serialize_contour() { + fn serialize_contour() { let contour = Contour::new().color("#123456").show(true).width(6); let expected = json!({"color": "#123456", "show": true, "width": 6}); @@ -445,7 +445,7 @@ mod tests { } #[test] - fn test_serialize_lighting() { + fn serialize_lighting() { let lighting = Lighting::new() .ambient(0.1) .diffuse(0.2) @@ -468,7 +468,7 @@ mod tests { } #[test] - fn test_serialize_light_position() { + fn serialize_light_position() { let light_position = LightPosition::new() .x(vec![10.0]) .y(vec![20.0]) @@ -479,7 +479,7 @@ mod tests { } #[test] - fn test_serialize_mesh3d() { + fn serialize_mesh3d() { let mesh3d = Mesh3D::new( vec![0.0, 1.0, 2.0], vec![3.0, 4.0, 5.0], diff --git a/plotly/src/traces/ohlc.rs b/plotly/src/traces/ohlc.rs index 7067514f..636f88f1 100644 --- a/plotly/src/traces/ohlc.rs +++ b/plotly/src/traces/ohlc.rs @@ -110,7 +110,7 @@ mod test { use super::*; #[test] - fn test_serialize_default_ohlc() { + fn serialize_default_ohlc() { let trace = Ohlc::::default(); let expected = json!({"type": "ohlc"}); @@ -118,7 +118,7 @@ mod test { } #[test] - fn test_serialize_ohlc() { + fn serialize_ohlc() { let trace = Ohlc::new( vec![0, 1], vec![5.0, 6.0], diff --git a/plotly/src/traces/sankey.rs b/plotly/src/traces/sankey.rs index 1809b10e..87453c3f 100644 --- a/plotly/src/traces/sankey.rs +++ b/plotly/src/traces/sankey.rs @@ -372,7 +372,7 @@ mod tests { use crate::color::NamedColor; #[test] - fn test_serialize_default_sankey() { + fn serialize_default_sankey() { let trace = Sankey::::default(); let expected = json!({"type": "sankey"}); @@ -380,7 +380,7 @@ mod tests { } #[test] - fn test_serialize_basic_sankey_trace() { + fn serialize_basic_sankey_trace() { // Mimic the plot here, minus the layout: // https://plotly.com/javascript/sankey-diagram/#basic-sankey-diagram let trace = Sankey::new() @@ -431,7 +431,7 @@ mod tests { } #[test] - fn test_serialize_full_sankey_trace() { + fn serialize_full_sankey_trace() { let trace = Sankey::::new() .name("sankey") .visible(true) @@ -474,7 +474,7 @@ mod tests { } #[test] - fn test_serialize_arrangement() { + fn serialize_arrangement() { assert_eq!(to_value(Arrangement::Snap).unwrap(), json!("snap")); assert_eq!( to_value(Arrangement::Perpendicular).unwrap(), @@ -485,7 +485,7 @@ mod tests { } #[test] - fn test_serialize_line() { + fn serialize_line() { let line = Line::new() .color_array(vec![NamedColor::Black, NamedColor::Blue]) .color(NamedColor::Black) @@ -499,7 +499,7 @@ mod tests { } #[test] - fn test_serialize_node() { + fn serialize_node() { let node = Node::new() .color(NamedColor::Blue) .color_array(vec![NamedColor::Blue]) @@ -527,7 +527,7 @@ mod tests { } #[test] - fn test_serialize_link() { + fn serialize_link() { let link = Link::new() .color_array(vec![NamedColor::Blue]) .color(NamedColor::Blue) diff --git a/plotly/src/traces/scatter.rs b/plotly/src/traces/scatter.rs index da81526e..e96784c3 100644 --- a/plotly/src/traces/scatter.rs +++ b/plotly/src/traces/scatter.rs @@ -409,7 +409,7 @@ mod tests { use super::*; #[test] - fn test_serialize_group_norm() { + fn serialize_group_norm() { assert_eq!(to_value(GroupNorm::Default).unwrap(), json!("")); assert_eq!(to_value(GroupNorm::Fraction).unwrap(), json!("fraction")); assert_eq!(to_value(GroupNorm::Percent).unwrap(), json!("percent")); @@ -417,13 +417,13 @@ mod tests { #[test] #[rustfmt::skip] - fn test_serialize_stack_gaps() { + fn serialize_stack_gaps() { assert_eq!(to_value(StackGaps::InferZero).unwrap(), json!("infer zero")); assert_eq!(to_value(StackGaps::Interpolate).unwrap(), json!("interpolate")); } #[test] - fn test_serialize_default_scatter() { + fn serialize_default_scatter() { let trace = Scatter::::default(); let expected = json!({"type": "scatter"}); @@ -431,7 +431,7 @@ mod tests { } #[test] - fn test_serialize_scatter() { + fn serialize_scatter() { use crate::common::ErrorType; let trace = Scatter::new(vec![0, 1], vec![2, 3]) diff --git a/plotly/src/traces/scatter3d.rs b/plotly/src/traces/scatter3d.rs index e8a0e3b9..762c30d9 100644 --- a/plotly/src/traces/scatter3d.rs +++ b/plotly/src/traces/scatter3d.rs @@ -315,7 +315,7 @@ mod tests { use crate::common::ErrorType; #[test] - fn test_serialize_projection() { + fn serialize_projection() { let projection = Projection::new() .x(ProjectionCoord::new()) .y(ProjectionCoord::new()) @@ -326,7 +326,7 @@ mod tests { } #[test] - fn test_serialize_projection_coord() { + fn serialize_projection_coord() { let projection_coord = ProjectionCoord::new().opacity(0.75).scale(5.0).show(false); let expected = json!({"opacity": 0.75, "scale": 5.0, "show": false}); @@ -334,7 +334,7 @@ mod tests { } #[test] - fn test_serialize_surface_axis() { + fn serialize_surface_axis() { assert_eq!(to_value(SurfaceAxis::MinusOne).unwrap(), json!("-1")); assert_eq!(to_value(SurfaceAxis::Zero).unwrap(), json!("0")); assert_eq!(to_value(SurfaceAxis::One).unwrap(), json!("1")); @@ -342,7 +342,7 @@ mod tests { } #[test] - fn test_serialize_default_scatter3d() { + fn serialize_default_scatter3d() { let trace = Scatter3D::::default(); let expected = json!({"type": "scatter3d"}).to_string(); @@ -350,7 +350,7 @@ mod tests { } #[test] - fn test_serialize_scatter3d() { + fn serialize_scatter3d() { let trace = Scatter3D::new(vec![0, 1], vec![2, 3], vec![4, 5]) .connect_gaps(true) .custom_data(vec!["custom_data"]) diff --git a/plotly/src/traces/scatter_mapbox.rs b/plotly/src/traces/scatter_mapbox.rs index 035632b4..f9feb171 100644 --- a/plotly/src/traces/scatter_mapbox.rs +++ b/plotly/src/traces/scatter_mapbox.rs @@ -290,13 +290,13 @@ mod tests { use super::*; #[test] - fn test_serialize_fill() { + fn serialize_fill() { assert_eq!(to_value(Fill::None).unwrap(), json!("none")); assert_eq!(to_value(Fill::ToSelf).unwrap(), json!("toself")); } #[test] - fn test_serialize_selection() { + fn serialize_selection() { let selection = Selection::new().color("#123456").opacity(0.5).size(6); let expected = json!({"marker": {"color": "#123456", "opacity": 0.5, "size": 6}}); @@ -304,7 +304,7 @@ mod tests { } #[test] - fn test_serialize_scatter_mapbox() { + fn serialize_scatter_mapbox() { let scatter_mapbox = ScatterMapbox::new(vec![45.5017], vec![-73.5673]) .name("name") .visible(Visible::True) diff --git a/plotly/src/traces/scatter_polar.rs b/plotly/src/traces/scatter_polar.rs index 4f9b4f1f..cd435a71 100644 --- a/plotly/src/traces/scatter_polar.rs +++ b/plotly/src/traces/scatter_polar.rs @@ -340,7 +340,7 @@ mod tests { use super::*; #[test] - fn test_serialize_default_scatter_polar() { + fn serialize_default_scatter_polar() { let trace = ScatterPolar::::default(); let expected = json!({"type": "scatterpolar"}); @@ -348,7 +348,7 @@ mod tests { } #[test] - fn test_serialize_scatter_polar() { + fn serialize_scatter_polar() { let trace = ScatterPolar::new(vec![0, 1], vec![2, 3]) .clip_on_axis(true) .connect_gaps(false) diff --git a/plotly/src/traces/surface.rs b/plotly/src/traces/surface.rs index 3f692543..5eeacfbc 100644 --- a/plotly/src/traces/surface.rs +++ b/plotly/src/traces/surface.rs @@ -207,7 +207,7 @@ mod tests { use crate::common::ColorScalePalette; #[test] - fn test_serialize_lighting() { + fn serialize_lighting() { let lighting = Lighting::new() .ambient(0.0) .diffuse(1.0) @@ -227,7 +227,7 @@ mod tests { } #[test] - fn test_serialize_position() { + fn serialize_position() { let position = Position::new(0, 1, 2); let expected = json!({ "x": 0, @@ -239,7 +239,7 @@ mod tests { } #[test] - fn test_serialize_plane_project() { + fn serialize_plane_project() { let plane_project = PlaneProject::new().x(true).y(false).z(true); let expected = json!({ "x": true, @@ -251,7 +251,7 @@ mod tests { } #[test] - fn test_serialize_plane_contours() { + fn serialize_plane_contours() { let plane_contours = PlaneContours::new() .color("#123456") .highlight(true) @@ -283,7 +283,7 @@ mod tests { } #[test] - fn test_serialize_surface_contours() { + fn serialize_surface_contours() { let surface_contours = SurfaceContours::new() .x(PlaneContours::new()) .y(PlaneContours::new()) @@ -299,7 +299,7 @@ mod tests { } #[test] - fn test_serialize_default_surface() { + fn serialize_default_surface() { let trace = Surface::::default(); let expected = json!({"type": "surface"}); @@ -307,7 +307,7 @@ mod tests { } #[test] - fn test_serialize_surface() { + fn serialize_surface() { let trace = Surface::new(vec![vec![0, 1]]) .x(vec![2, 3]) .y(vec![4, 5]) diff --git a/plotly/src/traces/table.rs b/plotly/src/traces/table.rs index 58545a57..2de3b0f2 100644 --- a/plotly/src/traces/table.rs +++ b/plotly/src/traces/table.rs @@ -157,7 +157,7 @@ mod tests { use super::*; #[test] - fn test_serialize_table() { + fn serialize_table() { let columns = Header::new(vec![String::from("col1"), String::from("col2")]); let values = Cells::new(vec![vec![1, 2], vec![2, 3]]); let trace = Table::new(columns, values); diff --git a/plotly_kaleido/src/lib.rs b/plotly_kaleido/src/lib.rs index f18dfb0d..cddcaf44 100644 --- a/plotly_kaleido/src/lib.rs +++ b/plotly_kaleido/src/lib.rs @@ -289,12 +289,12 @@ mod tests { } #[test] - fn test_can_find_kaleido_executable() { + fn can_find_kaleido_executable() { let _k = Kaleido::new(); } #[test] - fn test_plot_data_to_json() { + fn plot_data_to_json() { let test_plot = create_test_plot(); let kaleido_data = PlotData::new(&test_plot, "png", 400, 500, 1.); let expected = json!({ @@ -311,7 +311,7 @@ mod tests { // This seems to fail unpredictably on MacOs. #[cfg(not(target_os = "macos"))] #[test] - fn test_save_png() { + fn save_png() { let test_plot = create_test_plot(); let k = Kaleido::new(); let dst = PathBuf::from("example.png"); @@ -323,7 +323,7 @@ mod tests { // This seems to fail unpredictably on MacOs. #[cfg(not(target_os = "macos"))] #[test] - fn test_save_jpeg() { + fn save_jpeg() { let test_plot = create_test_plot(); let k = Kaleido::new(); let dst = PathBuf::from("example.jpeg"); @@ -335,7 +335,7 @@ mod tests { // This seems to fail unpredictably on MacOs. #[cfg(not(target_os = "macos"))] #[test] - fn test_save_webp() { + fn save_webp() { let test_plot = create_test_plot(); let k = Kaleido::new(); let dst = PathBuf::from("example.webp"); @@ -347,7 +347,7 @@ mod tests { // This seems to fail unpredictably on MacOs. #[cfg(not(target_os = "macos"))] #[test] - fn test_save_svg() { + fn save_svg() { let test_plot = create_test_plot(); let k = Kaleido::new(); let dst = PathBuf::from("example.svg"); @@ -359,7 +359,7 @@ mod tests { // This seems to fail unpredictably on MacOs. #[cfg(not(target_os = "macos"))] #[test] - fn test_save_pdf() { + fn save_pdf() { let test_plot = create_test_plot(); let k = Kaleido::new(); let dst = PathBuf::from("example.pdf"); @@ -371,7 +371,7 @@ mod tests { // This generates empty eps files for some reason #[test] #[ignore] - fn test_save_eps() { + fn save_eps() { let test_plot = create_test_plot(); let k = Kaleido::new(); let dst = PathBuf::from("example.eps"); From 5abb2d3e25e6a6bf3bceb36f11405beb5b341107 Mon Sep 17 00:00:00 2001 From: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com> Date: Thu, 2 Jan 2025 11:44:23 +0100 Subject: [PATCH 3/3] bump crate version to 0.12 Signed-off-by: Andrei Gherghescu <8067229+andrei-ng@users.noreply.github.com> --- CHANGELOG.md | 1 + README.md | 8 ++++---- docs/book/src/getting_started.md | 4 ++-- plotly/Cargo.toml | 8 ++++---- plotly_derive/Cargo.toml | 2 +- plotly_kaleido/Cargo.toml | 4 ++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 515f0e01..5caf4cc1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) a ### Fixed - [[#265](https://github.com/plotly/plotly.rs/pull/265)] Add Pie Chart trace +- [[#264](https://github.com/plotly/plotly.rs/issues/264)] Derive Deserialize on NamedColor, Rgb and Rgba - [[#216](https://github.com/plotly/plotly.rs/issues/216)] Opt out of downloading Kaleido binaries and allow users to set Kaleido path via environment variable - [[#259](https://github.com/plotly/plotly.rs/issues/259)] Mesh3d::new() has wrong signature - [[#175](https://github.com/plotly/plotly.rs/issues/175)] Put multiple subplots in the same html - added an example using `build_html` crate. diff --git a/README.md b/README.md index cd2c4883..2d2528ab 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Add this to your `Cargo.toml`: ```toml [dependencies] -plotly = "0.11" +plotly = "0.12" ``` ## Exporting a single Interactive Plot @@ -116,7 +116,7 @@ Enable the `kaleido` feature and opt in for automatic downloading of the `kaleid # Cargo.toml [dependencies] -plotly = { version = "0.11", features = ["kaleido", "kaleido_download"] } +plotly = { version = "0.12", features = ["kaleido", "kaleido_download"] } ``` Alternatively, enable only the `kaleido` feature and manually install Kaleido. @@ -124,7 +124,7 @@ Alternatively, enable only the `kaleido` feature and manually install Kaleido. # Cargo.toml [dependencies] -plotly = { version = "0.11", features = ["kaleido"] } +plotly = { version = "0.12", features = ["kaleido"] } ``` With the feature enabled, plots can be saved as any of `png`, `jpeg`, `webp`, `svg`, `pdf` and `eps`. Note that the plot will be a static image, i.e. they will be non-interactive. @@ -149,7 +149,7 @@ Using `Plotly.rs` in a Wasm-based frontend framework is possible by enabling the # Cargo.toml [dependencies] -plotly = { version = "0.11", features = ["wasm"] } +plotly = { version = "0.12", features = ["wasm"] } ``` First, make sure that you have the Plotly JavaScript library in your base HTML template: diff --git a/docs/book/src/getting_started.md b/docs/book/src/getting_started.md index 9caf0b30..12744c46 100644 --- a/docs/book/src/getting_started.md +++ b/docs/book/src/getting_started.md @@ -22,7 +22,7 @@ To start using [plotly.rs](https://github.com/plotly/plotly.rs) in your project ```toml [dependencies] -plotly = "0.11" +plotly = "0.12" ``` [Plotly.rs](https://github.com/plotly/plotly.rs) is ultimately a thin wrapper around the `plotly.js` library. The main job of this library is to provide `structs` and `enums` which get serialized to `json` and passed to the `plotly.js` library to actually do the heavy lifting. As such, if you are familiar with `plotly.js` or its derivatives (e.g. the equivalent Python library), then you should find [`plotly.rs`](https://github.com/plotly/plotly.rs) intuitive to use. @@ -97,7 +97,7 @@ To add the ability to save plots in the following formats: png, jpeg, webp, svg, ```toml [dependencies] -plotly = { version = "0.11", features = ["kaleido"] } +plotly = { version = "0.12", features = ["kaleido"] } ``` ## WebAssembly Support diff --git a/plotly/Cargo.toml b/plotly/Cargo.toml index 592a3071..bbb77124 100644 --- a/plotly/Cargo.toml +++ b/plotly/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "plotly" -version = "0.11.0" +version = "0.12.0" description = "A plotting library powered by Plotly.js" authors = ["Ioannis Giagkiozis "] license = "MIT" @@ -32,8 +32,8 @@ erased-serde = "0.4" getrandom = { version = "0.2", features = ["js"], optional = true } image = { version = "0.25", optional = true } js-sys = { version = "0.3", optional = true } -plotly_derive = { version = "0.11", path = "../plotly_derive" } -plotly_kaleido = { version = "0.11", path = "../plotly_kaleido", optional = true } +plotly_derive = { version = "0.12", path = "../plotly_derive" } +plotly_kaleido = { version = "0.12", path = "../plotly_kaleido", optional = true } ndarray = { version = "0.16", optional = true } once_cell = "1" serde = { version = "1.0", features = ["derive"] } @@ -50,7 +50,7 @@ image = "0.25" itertools = ">=0.10, <0.15" itertools-num = "0.1" ndarray = "0.16" -plotly_kaleido = { version = "0.11", path = "../plotly_kaleido", features = [ +plotly_kaleido = { version = "0.12", path = "../plotly_kaleido", features = [ "download", ] } rand_distr = "0.4" diff --git a/plotly_derive/Cargo.toml b/plotly_derive/Cargo.toml index b744b0d9..65acd533 100644 --- a/plotly_derive/Cargo.toml +++ b/plotly_derive/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "plotly_derive" -version = "0.11.0" +version = "0.12.0" description = "Internal proc macro crate for Plotly-rs." authors = ["Ioannis Giagkiozis "] license = "MIT" diff --git a/plotly_kaleido/Cargo.toml b/plotly_kaleido/Cargo.toml index 5a1829ba..f900689e 100644 --- a/plotly_kaleido/Cargo.toml +++ b/plotly_kaleido/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "plotly_kaleido" -version = "0.11.0" +version = "0.12.0" description = "Additional output format support for plotly using Kaleido" authors = [ "Ioannis Giagkiozis ", @@ -27,7 +27,7 @@ dunce = "1.0" base64 = "0.22" [dev-dependencies] -plotly_kaleido = { version = "0.11", path = ".", features = ["download"] } +plotly_kaleido = { version = "0.12", path = ".", features = ["download"] } [build-dependencies] zip = "2.1"