Skip to content

Commit

Permalink
Update comments to reflect correct function names and error types
Browse files Browse the repository at this point in the history
The comments for each function in interpolation/spline/natural_cubic.rs, interpolation/spline/hermite.rs, and interpolation/spline/catmull_rom.rs have been updated to reflect the correct function names and error types. This includes changing instances where 'HermiteSpline' was incorrectly used, to the correct function names 'NaturalCubic', 'Hermite', and 'CatmullRom' respectively, and updating the error type from 'HermiteSplineError' to 'InterpolationError'.
  • Loading branch information
nakashima-hikaru committed Jun 11, 2024
1 parent 2f4f900 commit b822935
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
10 changes: 5 additions & 5 deletions crates/qlab-math/src/interpolation/spline/catmull_rom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ pub struct CatmullRom<V: Value> {
}

impl<V: Value> Interpolator<V> for CatmullRom<V> {
/// Constructs a new `CatmullRomSpline` from a slice of raw points.
/// Constructs a new `CatmullRom` from a slice of raw points.
///
/// # Arguments
///
/// * `raw_points` - A slice of tuples containing raw points `(x, y)` where `x` is the x-coordinate and `y` is the y-coordinate.
///
/// # Returns
///
/// * `Result<Self, HermiteSplineError<V>>` - A `Result` that either contains the constructed `HermiteSpline` or an `HermiteSplineError`.
/// * `Result<Self, InterpolationError<V>>` - A `Result` that either contains the constructed `CatmullRom` or an `InterpolationError`.
///
/// # Errors
///
/// * `HermiteSplineError::InsufficientPointsError(n)` - If the number of `raw_points` is less than 3, where `n` is the number of `raw_points`.
/// * `HermiteSplineError::PointOrderError` - If the x-coordinates of the `raw_points` are not in ascending order.
/// * `InterpolationError::InsufficientPointsError(n)` - If the number of `raw_points` is less than 3, where `n` is the number of `raw_points`.
/// * `InterpolationError::PointOrderError` - If the x-coordinates of the `raw_points` are not in ascending order.
///
fn try_fit(&mut self, raw_points: &[(V, V)]) -> Result<(), InterpolationError<V>> {
if raw_points.len() < 3 {
Expand Down Expand Up @@ -59,7 +59,7 @@ impl<V: Value> Interpolator<V> for CatmullRom<V> {
/// # Returns
///
/// * `Ok(V)`: If the value `x` is found in the Hermite spline, returns the corresponding value `V`.
/// * `Err(HermiteSplineError<V>)`: If the value `x` is not found, returns an error indicating whether `x` is out of the lower or upper bound of the spline.
/// * `Err(InterpolationError<V>)`: If the value `x` is not found, returns an error indicating whether `x` is out of the lower or upper bound of the spline.
///
/// # Errors
/// If `x` is below the lower bound of the spline's points, returns `Err(OutOfLowerBound(x))`.
Expand Down
8 changes: 4 additions & 4 deletions crates/qlab-math/src/interpolation/spline/hermite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct Hermite<V: Value> {
}

impl<V: Value> Hermite<V> {
/// Creates a new instance of `HermiteSpline` from a slice of raw points.
/// Creates a new instance of `Hermite` from a slice of raw points.
///
/// # Arguments
///
Expand All @@ -27,12 +27,12 @@ impl<V: Value> Hermite<V> {
/// # Returns
///
/// Returns a `Result` containing the constructed `HermiteSpline` on success,
/// or a `HermiteSplineError` if the raw points are not in ascending order based on x-coordinate.
/// or a `InterpolationError` if the raw points are not in ascending order based on x-coordinate.
///
/// # Errors
///
/// * `HermiteSplineError::InsufficientPointsError(n)` - If the number of `raw_points` is less than 3, where `n` is the number of `raw_points`.
/// * `HermiteSplineError::PointOrderError` - If the x-coordinates of the `raw_points` are not in ascending order.
/// * `InterpolationError::InsufficientPointsError(n)` - If the number of `raw_points` is less than 3, where `n` is the number of `raw_points`.
/// * `InterpolationError::PointOrderError` - If the x-coordinates of the `raw_points` are not in ascending order.
///
/// # Panics
/// Will panic if `V` fail to cast constants.
Expand Down
6 changes: 3 additions & 3 deletions crates/qlab-math/src/interpolation/spline/natural_cubic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct NaturalCubic<V: Value> {
}

impl<V: Value> Interpolator<V> for NaturalCubic<V> {
/// Tries to create a new `HermiteSpline` from the given raw points.
/// Tries to create a new `NaturalCubic` from the given raw points.
///
/// # Arguments
///
Expand All @@ -26,8 +26,8 @@ impl<V: Value> Interpolator<V> for NaturalCubic<V> {
///
/// # Returns
///
/// Returns `Ok(Self)` if the `HermiteSpline` is successfully created, otherwise returns a
/// `HermiteSplineError`.
/// Returns `Ok(Self)` if the `NaturalCubic` is successfully created, otherwise returns a
/// `InterpolationError`.
///
/// # Errors
///
Expand Down

0 comments on commit b822935

Please sign in to comment.