feat(core): minor additions to the API
This commit is contained in:
parent
c666498ac0
commit
e22410eea8
3 changed files with 19 additions and 4 deletions
|
|
@ -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};
|
||||
|
|
|
|||
|
|
@ -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<T> Signal<T> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T: Num> Signal<T> {
|
||||
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::*;
|
||||
|
|
|
|||
|
|
@ -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<bool> = sync_points
|
||||
let sig: Option<Signal<bool>> = 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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue