Skip to content

Commit

Permalink
downgrade ndarray dep
Browse files Browse the repository at this point in the history
  • Loading branch information
kylecarow committed Jan 14, 2025
1 parent 45daa06 commit 3f74769
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

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

2 changes: 1 addition & 1 deletion fastsim-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ include_dir = { version = "0.7.3", optional = true }
itertools = "0.12.0"
lazy_static = "1.4.0"
regex = "1.10.3"
ndarray = "0.16.1"
ndarray = "0.15.6"
toml = { version = "0.8.12", optional = true }
derive_more = { version = "1.0.0", features = ["from_str", "from", "is_variant", "try_into"] }
ureq = { version = "2.9.1", optional = true }
Expand Down
26 changes: 10 additions & 16 deletions fastsim-core/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ impl Min for Vec<&f64> {
}
impl Min for &[Vec<f64>] {
fn min(&self) -> anyhow::Result<f64> {
self
.iter()
self.iter()
.map(|v| v.min())
.try_fold(f64::INFINITY, |acc, x| Ok(acc.min(x?)))
}
Expand All @@ -69,19 +68,17 @@ impl Min for Vec<Vec<Vec<f64>>> {
self.as_slice().min()
}
}
impl Min for &ArrayD<f64> {
fn min(&self) -> anyhow::Result<f64> {
Ok(self.iter().fold(f64::INFINITY, |acc, x| acc.min(*x)))
}
}
impl Min for Interpolator {
fn min(&self) -> anyhow::Result<f64> {
match self {
Interpolator::Interp0D(value) => Ok(*value),
Interpolator::Interp1D(interp) => interp.f_x().min(),
Interpolator::Interp2D(interp) => interp.f_xy().min(),
Interpolator::Interp3D(interp) => interp.f_xyz().min(),
Interpolator::InterpND(interp) => interp.values().min(),
Interpolator::InterpND(interp) => Ok(interp
.values()
.iter()
.fold(f64::INFINITY, |acc, x| acc.min(*x))),
}
}
}
Expand Down Expand Up @@ -115,8 +112,7 @@ impl Max for Vec<&f64> {
}
impl Max for &[Vec<f64>] {
fn max(&self) -> anyhow::Result<f64> {
self
.iter()
self.iter()
.map(|v| v.max())
.try_fold(f64::NEG_INFINITY, |acc, x| Ok(acc.max(x?)))
}
Expand All @@ -138,19 +134,17 @@ impl Max for Vec<Vec<Vec<f64>>> {
self.as_slice().max()
}
}
impl Max for &ArrayD<f64> {
fn max(&self) -> anyhow::Result<f64> {
Ok(self.iter().fold(f64::NEG_INFINITY, |acc, x| acc.max(*x)))
}
}
impl Max for Interpolator {
fn max(&self) -> anyhow::Result<f64> {
match self {
Interpolator::Interp0D(value) => Ok(*value),
Interpolator::Interp1D(interp) => interp.f_x().max(),
Interpolator::Interp2D(interp) => interp.f_xy().max(),
Interpolator::Interp3D(interp) => interp.f_xyz().max(),
Interpolator::InterpND(interp) => interp.values().max(),
Interpolator::InterpND(interp) => Ok(interp
.values()
.iter()
.fold(f64::NEG_INFINITY, |acc, x| acc.max(*x))),
}
}
}
Expand Down

0 comments on commit 3f74769

Please sign in to comment.