forked from deepcausality-rs/deep_causality
-
Notifications
You must be signed in to change notification settings - Fork 0
/
utils_shared.rs
28 lines (23 loc) · 883 Bytes
/
utils_shared.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// SPDX-License-Identifier: MIT
// Copyright (c) "2023" . The DeepCausality Authors. All Rights Reserved.
use deep_causality::errors::CausalityError;
use deep_causality::prelude::{BaseCausaloid, Causaloid, IdentificationValue, NumericalValue};
pub fn get_test_causaloid<'l>() -> BaseCausaloid<'l> {
let id: IdentificationValue = 1;
let description = "tests whether data exceeds threshold of 0.55";
fn causal_fn(obs: NumericalValue) -> Result<bool, CausalityError> {
if obs.is_sign_negative() {
return Err(CausalityError("Observation is negative".into()));
}
let threshold: NumericalValue = 0.55;
if !obs.ge(&threshold) {
Ok(false)
} else {
Ok(true)
}
}
Causaloid::new(id, causal_fn, description)
}
pub fn generate_sample_data<const N: usize>() -> [f64; N] {
[0.99; N]
}