diff --git a/argus-core/src/prelude.rs b/argus-core/src/prelude.rs index 2b12a41..8a33116 100644 --- a/argus-core/src/prelude.rs +++ b/argus-core/src/prelude.rs @@ -1,3 +1,7 @@ pub use crate::expr::{BoolExpr, Expr, ExprBuilder, ExprRef, NumExpr}; +pub use crate::signals::bool_ops::*; +pub use crate::signals::cast::*; +pub use crate::signals::cmp_ops::*; +pub use crate::signals::num_ops::*; pub use crate::signals::Signal; pub use crate::{ArgusError, ArgusResult}; diff --git a/argus-core/src/signals.rs b/argus-core/src/signals.rs index e3d3e2d..d1e1abe 100644 --- a/argus-core/src/signals.rs +++ b/argus-core/src/signals.rs @@ -24,7 +24,7 @@ pub use cast::*; pub use cmp_ops::*; use itertools::Itertools; pub use num_ops::*; -use num_traits::NumCast; +use num_traits::{Num, NumCast}; pub use traits::*; use utils::intersect_bounds; @@ -396,6 +396,16 @@ impl Signal { } } +impl Signal { + pub fn zero() -> Self { + Signal::constant(T::zero()) + } + + pub fn one() -> Self { + Signal::constant(T::one()) + } +} + #[cfg(any(test, feature = "arbitrary"))] pub mod arbitrary { use proptest::prelude::*; diff --git a/argus-core/src/signals/cmp_ops.rs b/argus-core/src/signals/cmp_ops.rs index 5b79853..3732bf5 100644 --- a/argus-core/src/signals/cmp_ops.rs +++ b/argus-core/src/signals/cmp_ops.rs @@ -20,15 +20,16 @@ where // added to the signal appropriately. // the union of the sample points in self and other let sync_points = self.sync_with_intersection(other)?; - let sig: Signal = sync_points + let sig: Option> = sync_points .into_iter() .map(|t| { let lhs = self.interpolate_at(t, Linear).unwrap(); let rhs = other.interpolate_at(t, Linear).unwrap(); - (t, op(lhs.partial_cmp(&rhs).unwrap())) + let cmp = lhs.partial_cmp(&rhs); + cmp.map(|v| (t, op(v))) }) .collect(); - Some(sig) + sig } }