Skip to content

Commit

Permalink
refactor: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nakashima-hikaru committed Apr 6, 2024
1 parent 7cc4d7a commit e165494
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions crates/qlab-math/src/interpolation/linear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ use qlab_error::ComputeError::InvalidInput;
use qlab_error::QLabResult;
use std::fmt::Debug;

/// A linear data structure that stores a collection of points.
///
/// # Type Parameters
///
/// - `V`: The type of values in the points.
///
/// # Examples
///
/// ```
/// use num_traits::Float;
/// use qlab_math::interpolation::linear::Linear;
/// use qlab_math::interpolation::Method;
///
/// let mut linear: Linear<f32> = Linear::default();
///
/// let xs = [1.0, 3.0];
/// let ys = [2.0, 4.0];
/// linear.fit(&xs, &ys).unwrap();
/// assert_eq!(linear.value(2.0).unwrap(), 3.0);
///
/// ```
#[derive(Default)]
pub struct Linear<V: Float> {
points: Vec<Point<V>>,
Expand Down
4 changes: 1 addition & 3 deletions crates/qlab-time/src/day_count/act_360.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ impl DayCount for Act360 {
))?;
let denomination =
V::from_i32(360).ok_or(ComputeError::CastNumberError(format!("{}", 360).into()))?;
if denomination.eq(&V::zero()) {
return Err(ComputeError::ZeroDivisionError.into());
}

Ok(date_diff.div(denomination))
}
}
Expand Down
4 changes: 1 addition & 3 deletions crates/qlab-time/src/day_count/act_365.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ impl DayCount for Act365 {
))?;
let denomination =
V::from_i32(365).ok_or(ComputeError::CastNumberError(format!("{}", 365).into()))?;
if denomination.eq(&V::zero()) {
return Err(ComputeError::ZeroDivisionError.into());
}

Ok(date_diff.div(denomination))
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/qlab-time/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
mod business_day_convention;
pub mod business_day_convention;
// mod calendar;
mod calendar;
pub mod date;
Expand Down
1 change: 1 addition & 0 deletions crates/qlab/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ qlab-time = { workspace = true }
qlab-termstructure = { workspace = true }
qlab-instrument = { workspace = true }
qlab-math = { workspace = true }
calendar = { workspace = true }

[lints]
workspace = true

0 comments on commit e165494

Please sign in to comment.