diff --git a/src/coordinate.rs b/src/coordinate.rs index 4fa1cc3..3bd05d5 100644 --- a/src/coordinate.rs +++ b/src/coordinate.rs @@ -11,7 +11,7 @@ pub trait Coordinate: /// # Examples /// /// ``` - /// use crate::coordinate::Coordinate; + /// use pav_regression::Coordinate; /// /// let zero = f64::zero(); /// assert_eq!(zero, 0.0); @@ -23,7 +23,7 @@ pub trait Coordinate: /// # Examples /// /// ``` - /// use crate::coordinate::Coordinate; + /// use pav_regression::Coordinate; /// /// let one = f64::one(); /// assert_eq!(one, 1.0); @@ -35,7 +35,7 @@ pub trait Coordinate: /// # Examples /// /// ``` - /// use crate::coordinate::Coordinate; + /// use pav_regression::Coordinate; /// /// let value: f64 = 3.14; /// assert_eq!(value.to_float(), 3.14); @@ -47,7 +47,7 @@ pub trait Coordinate: /// # Examples /// /// ``` - /// use crate::coordinate::Coordinate; + /// use pav_regression::Coordinate; /// /// let value = f64::from_float(3.14); /// assert_eq!(value, 3.14); @@ -59,7 +59,7 @@ pub trait Coordinate: /// # Examples /// /// ``` - /// use crate::coordinate::Coordinate; + /// use pav_regression::Coordinate; /// /// let a: f64 = 2.5; /// let b: f64 = -1.5; @@ -72,7 +72,7 @@ pub trait Coordinate: /// # Examples /// /// ``` - /// use crate::coordinate::Coordinate; + /// use pav_regression::Coordinate; /// /// let a: f64 = -1.0; /// assert!(a.is_sign_negative()); @@ -87,7 +87,7 @@ pub trait Coordinate: /// # Examples /// /// ``` - /// use crate::coordinate::Coordinate; + /// use pav_regression::Coordinate; /// /// let a: f64 = 2.0; /// let b: f64 = 4.0; diff --git a/src/isotonic_regression.rs b/src/isotonic_regression.rs index 76be879..d9819f6 100644 --- a/src/isotonic_regression.rs +++ b/src/isotonic_regression.rs @@ -63,14 +63,15 @@ impl IsotonicRegression { /// # Examples /// /// ``` + /// use pav_regression::{Point, IsotonicRegression}; /// /// let points = vec![ - /// super::point::Point::new(0.0, 1.0), - /// super::point::Point::new(1.0, 2.0), - /// super::point::Point::new(2.0, 1.5), - /// super::point::Point::new(3.0, 3.0), + /// Point::new(0.0, 1.0), + /// Point::new(1.0, 2.0), + /// Point::new(2.0, 1.5), + /// Point::new(3.0, 3.0), /// ]; - /// let regression = super::isotonic_regression::IsotonicRegression::new_ascending(&points).unwrap(); + /// let regression = IsotonicRegression::new_ascending(&points).unwrap(); /// assert_eq!(regression.get_points().len(), 3); /// ``` pub fn new_ascending(points: &[Point]) -> Result, IsotonicRegressionError> { @@ -82,13 +83,15 @@ impl IsotonicRegression { /// # Examples /// /// ``` + /// use pav_regression::{Point, IsotonicRegression}; + /// /// let points = vec![ - /// super::point::Point::new(0.0, 3.0), - /// super::point::Point::new(1.0, 2.0), - /// super::point::Point::new(2.0, 2.5), - /// super::point::Point::new(3.0, 1.0), + /// Point::new(0.0, 3.0), + /// Point::new(1.0, 2.0), + /// Point::new(2.0, 2.5), + /// Point::new(3.0, 1.0), /// ]; - /// let regression = super::isotonic_regression::IsotonicRegression::new_descending(&points).unwrap(); + /// let regression = IsotonicRegression::new_descending(&points).unwrap(); /// assert_eq!(regression.get_points().len(), 3); /// ``` pub fn new_descending(points: &[Point]) -> Result, IsotonicRegressionError> { @@ -102,13 +105,15 @@ impl IsotonicRegression { /// # Examples /// /// ``` + /// use pav_regression::{Point, IsotonicRegression, Direction}; + /// /// let points = vec![ - /// super::point::Point::new(0.0, 1.0), - /// super::point::Point::new(1.0, 2.0), - /// super::point::Point::new(2.0, 1.5), - /// super::point::Point::new(3.0, 3.0), + /// Point::new(0.0, 1.0), + /// Point::new(1.0, 2.0), + /// Point::new(2.0, 1.5), + /// Point::new(3.0, 3.0), /// ]; - /// let regression = super::isotonic_regression::IsotonicRegression::new(&points, super::isotonic_regression::Direction::Ascending, false).unwrap(); + /// let regression = IsotonicRegression::new(&points, Direction::Ascending, false).unwrap(); /// assert_eq!(regression.get_points().len(), 3); /// ``` fn new(points: &[Point], direction: Direction, intersect_origin: bool) -> Result, IsotonicRegressionError> { @@ -139,13 +144,15 @@ impl IsotonicRegression { /// # Examples /// /// ``` + /// use pav_regression::{Point, IsotonicRegression}; + /// /// let points = vec![ - /// super::point::Point::new(0.0, 1.0), - /// super::point::Point::new(1.0, 2.0), - /// super::point::Point::new(2.0, 1.5), - /// super::point::Point::new(3.0, 3.0), + /// Point::new(0.0, 1.0), + /// Point::new(1.0, 2.0), + /// Point::new(2.0, 1.5), + /// Point::new(3.0, 3.0), /// ]; - /// let regression = super::isotonic_regression::IsotonicRegression::new_ascending(&points).unwrap(); + /// let regression = IsotonicRegression::new_ascending(&points).unwrap(); /// let interpolated_y = regression.interpolate(1.5).unwrap(); /// assert_eq!(interpolated_y, 1.75); /// ``` @@ -199,13 +206,15 @@ impl IsotonicRegression { /// # Examples /// /// ``` + /// use pav_regression::{Point, IsotonicRegression}; + /// /// let points = vec![ - /// super::point::Point::new(0.0, 1.0), - /// super::point::Point::new(1.0, 2.0), - /// super::point::Point::new(2.0, 1.5), - /// super::point::Point::new(3.0, 3.0), + /// Point::new(0.0, 1.0), + /// Point::new(1.0, 2.0), + /// Point::new(2.0, 1.5), + /// Point::new(3.0, 3.0), /// ]; - /// let regression = super::isotonic_regression::IsotonicRegression::new_ascending(&points).unwrap(); + /// let regression = IsotonicRegression::new_ascending(&points).unwrap(); /// assert_eq!(regression.get_points().len(), 3); /// ``` pub fn get_points(&self) -> &[Point] { @@ -217,15 +226,17 @@ impl IsotonicRegression { /// # Examples /// /// ``` + /// use pav_regression::{Point, IsotonicRegression}; + /// /// let points = vec![ - /// super::point::Point::new(0.0, 1.0), - /// super::point::Point::new(1.0, 2.0), - /// super::point::Point::new(2.0, 1.5), - /// super::point::Point::new(3.0, 3.0), + /// Point::new(0.0, 1.0), + /// Point::new(1.0, 2.0), + /// Point::new(2.0, 1.5), + /// Point::new(3.0, 3.0), /// ]; - /// let regression = super::isotonic_regression::IsotonicRegression::new_ascending(&points).unwrap(); + /// let regression = IsotonicRegression::new_ascending(&points).unwrap(); /// let centroid = regression.get_centroid_point().unwrap(); - /// assert_eq!(*centroid.x(), 1.0); + /// assert_eq!(*centroid.x(), 1.5); /// assert_eq!(*centroid.y(), 1.875); /// ``` pub fn get_centroid_point(&self) -> Option> { @@ -245,11 +256,13 @@ impl IsotonicRegression { /// # Examples /// /// ``` - /// let mut regression = super::isotonic_regression::IsotonicRegression::new_ascending(&[ - /// super::point::Point::new(0.0, 1.0), - /// super::point::Point::new(2.0, 2.0), + /// use pav_regression::{Point, IsotonicRegression}; + /// + /// let mut regression = IsotonicRegression::new_ascending(&[ + /// Point::new(0.0, 1.0), + /// Point::new(2.0, 2.0), /// ]).unwrap(); - /// regression.add_points(&[super::Point::new(1.0, 1.5)]); + /// regression.add_points(&[Point::new(1.0, 1.5)]); /// assert_eq!(regression.get_points().len(), 3); /// ``` pub fn add_points(&mut self, points: &[Point]) { @@ -272,12 +285,14 @@ impl IsotonicRegression { /// # Examples /// /// ``` - /// let mut regression = super::isotonic_regression::IsotonicRegression::new_ascending(&[ - /// super::point::Point::new(0.0, 1.0), - /// super::point::Point::new(1.0, 2.0), - /// super::point::Point::new(2.0, 3.0), + /// use pav_regression::{Point, IsotonicRegression}; + /// + /// let mut regression = IsotonicRegression::new_ascending(&[ + /// Point::new(0.0, 1.0), + /// Point::new(1.0, 2.0), + /// Point::new(2.0, 3.0), /// ]).unwrap(); - /// regression.remove_points(&[super::Point::new(1.0, 2.0)]); + /// regression.remove_points(&[Point::new(1.0, 2.0)]); /// assert_eq!(regression.get_points().len(), 2); /// ``` pub fn remove_points(&mut self, points: &[Point]) { @@ -303,16 +318,15 @@ impl IsotonicRegression { /// # Examples /// /// ``` - /// use super::point::Point; - /// use super::isotonic_regression::IsotonicRegression; + /// use pav_regression::{Point, IsotonicRegression}; /// /// let points = vec![ - /// super::Point::new(0.0, 1.0), - /// super::Point::new(1.0, 2.0), - /// super::Point::new(2.0, 1.5), - /// super::Point::new(3.0, 3.0), + /// Point::new(0.0, 1.0), + /// Point::new(1.0, 2.0), + /// Point::new(2.0, 1.5), + /// Point::new(3.0, 3.0), /// ]; - /// let regression = super::IsotonicRegression::new_ascending(&points).unwrap(); + /// let regression = IsotonicRegression::new_ascending(&points).unwrap(); /// assert_eq!(regression.len(), 4); /// ``` pub fn len(&self) -> usize { @@ -324,7 +338,9 @@ impl IsotonicRegression { /// # Examples /// /// ``` - /// let regression: super::isotonic_regression::IsotonicRegression = super::isotonic_regression::IsotonicRegression::new_ascending(&[]).unwrap(); + /// use pav_regression::IsotonicRegression; + /// + /// let regression: IsotonicRegression = IsotonicRegression::new_ascending(&[]).unwrap(); /// assert!(regression.is_empty()); /// ``` #[must_use] diff --git a/src/point.rs b/src/point.rs index ebfe56c..200a58e 100644 --- a/src/point.rs +++ b/src/point.rs @@ -25,7 +25,7 @@ impl Point { /// # Examples /// /// ``` - /// let point = crate::point::Point::new(1.0, 2.0); + /// use pav_regression::Point; /// /// let point = Point::new(1.0, 2.0); /// assert_eq!(*point.x(), 1.0); @@ -41,7 +41,7 @@ impl Point { /// # Examples /// /// ``` - /// let point = crate::point::Point::new_with_weight(1.0, 2.0, 0.5); + /// use pav_regression::Point; /// /// let point = Point::new_with_weight(1.0, 2.0, 0.5); /// assert_eq!(*point.x(), 1.0); @@ -57,7 +57,7 @@ impl Point { /// # Examples /// /// ``` - /// let point = crate::point::Point::new(1.0, 2.0); + /// use pav_regression::Point; /// /// let point = Point::new(1.0, 2.0); /// assert_eq!(*point.x(), 1.0); @@ -71,7 +71,7 @@ impl Point { /// # Examples /// /// ``` - /// let point = crate::point::Point::new(1.0, 2.0); + /// use pav_regression::Point; /// /// let point = Point::new(1.0, 2.0); /// assert_eq!(*point.y(), 2.0); @@ -85,7 +85,7 @@ impl Point { /// # Examples /// /// ``` - /// let point = crate::point::Point::new(1.0, 2.0); + /// use pav_regression::Point; /// /// let point = Point::new(1.0, 2.0); /// assert_eq!(point.weight(), 1.0); @@ -99,8 +99,7 @@ impl Point { /// # Examples /// /// ``` - /// let mut point1 = crate::point::Point::new_with_weight(1.0, 2.0, 0.5); - /// let point2 = crate::point::Point::new_with_weight(3.0, 4.0, 1.5); + /// use pav_regression::Point; /// /// let mut point1 = Point::new_with_weight(1.0, 2.0, 0.5); /// let point2 = Point::new_with_weight(3.0, 4.0, 1.5); @@ -129,8 +128,7 @@ impl From<(T, T)> for Point { /// # Examples /// /// ``` -/// let point1 = crate::point::Point::new(0.0, 0.0); -/// let point2 = crate::point::Point::new(2.0, 2.0); +/// use pav_regression::{Point, interpolate_two_points}; /// /// let point1 = Point::new(0.0, 0.0); /// let point2 = Point::new(2.0, 2.0);