From e0c102cce3a1a62d1521ff2b97a85affc114a8c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isa=C3=AFe?= Date: Thu, 30 May 2024 20:42:54 +0200 Subject: [PATCH] refactor: replace `num` dependency with `num-traits` (#18) --- Cargo.toml | 2 +- integraal/Cargo.toml | 2 +- integraal/src/structure/implementations.rs | 4 ++-- integraal/src/traits.rs | 12 ++++++------ 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 6fe7da5..80c82c4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,4 +26,4 @@ integraal-examples = { version = "0.0.2", path = "./examples" } # external rand = "0.9.0-alpha.1" rustversion = "1.0.15" -num = "0.4.3" +num-traits = "0.2.19" diff --git a/integraal/Cargo.toml b/integraal/Cargo.toml index 164ee97..4c4a6b5 100644 --- a/integraal/Cargo.toml +++ b/integraal/Cargo.toml @@ -20,7 +20,7 @@ montecarlo = ["dep:rand"] # DEPS [dependencies] -num.workspace = true +num-traits.workspace = true rand = { workspace = true, features = ["small_rng"], optional = true } [build-dependencies] diff --git a/integraal/src/structure/implementations.rs b/integraal/src/structure/implementations.rs index 6f84f26..c8806af 100644 --- a/integraal/src/structure/implementations.rs +++ b/integraal/src/structure/implementations.rs @@ -5,7 +5,6 @@ use crate::{ ComputeMethod, DomainDescriptor, FunctionDescriptor, Integraal, IntegraalError, Scalar, }; -use num::abs; use std::ops::Deref; // ------ CONTENT @@ -76,7 +75,8 @@ impl<'a, X: Scalar> Integraal<'a, X> { let step = args[idx] - args[idx - 1]; let y1 = vals[idx - 1]; let y2 = vals[idx]; - (y1.min(y2) + abs(y1 - y2) / X::from_f32(2.0).unwrap()) * step + (y1.min(y2) + num_traits::abs(y1 - y2) / X::from_f32(2.0).unwrap()) + * step }) .sum(), #[cfg(feature = "montecarlo")] diff --git a/integraal/src/traits.rs b/integraal/src/traits.rs index 52fa259..e51b26c 100644 --- a/integraal/src/traits.rs +++ b/integraal/src/traits.rs @@ -6,9 +6,9 @@ pub trait Scalar: Clone + Copy - + num::Float - + num::Signed - + num::FromPrimitive + + num_traits::Float + + num_traits::Signed + + num_traits::FromPrimitive + std::ops::Sub + std::ops::Mul + std::iter::Sum @@ -18,9 +18,9 @@ pub trait Scalar: impl< X: Clone + Copy - + num::Float - + num::Signed - + num::FromPrimitive + + num_traits::Float + + num_traits::Signed + + num_traits::FromPrimitive + std::ops::Sub + std::ops::Mul + std::iter::Sum,