#[cfg(test)] mod tests { use json::array; use df_helper::datetime::timer::Timer; use df_helper::maths::{ma, maths}; #[test] fn ma() { let data = array![670, 680, 690,680,700,720,730,740,740,760,780,790]; let data = ma::ma(data, 5.0, false); let data = array![423,358 ,434,445,527,429,502,480,384,427,446]; let data = ma::ma(data, 3.0, true); println!("{:#}", data); let data = array![423,358 ,434,445,527,429,502,480,384,427,446]; let data = ma::ma(data, 5.0, true); println!("{:#}", data); let data = array![35.0,34.0,37.0,36.0,35.0,38.0]; let data = ma::ma(data, 5.0, true); println!("{:#}", data); } #[test] fn expmema() { // let data = array![7297, 7441, 8666,10002,16320,17562]; // let data = array![7297, 7441, 8666,10002]; // let data = array![670, 680, 690,680,700,720,730,740,740,760,780,790]; // let data = array![8,2,4,4,6,6,3,7,1,3,8,5]; // let data = ma::expmema(data, 1.0); // println!("{:#}", data); let data = array![35,34,37,36,35,38,37,37,39,38,37]; let data = ma::expmema(data, 0.9); println!("{:#}", data); // let data = array![35,34,37,36,35,38,37,37,39,38,37]; let data = ma::xexpmema(data, 0.9); println!("{:#}", data); } #[test] fn ema() { let mut timer = Timer::start("ms"); let data = array![7297, 7441, 8666,10002,16320,17562]; // let data = array![7297, 7441, 8666,10002]; // let data = array![670, 680, 690,680,700,720,730,740,740,760,780,790]; let data = array![8,2,4,4,6,6,3,7,1,3,8,5]; let data = ma::ema(data, 3.0); timer.end(true); println!("{:#}", data); } #[test] fn wma() { // let data = array![7297, 7441, 8666,10002,16320,17562]; // // let data = array![7297, 7441, 8666,10002]; // // let data = array![670, 680, 690,680,700,720,730,740,740,760,780,790]; // let data = array![38,45,35,49,70,43,46,55,45,68,64]; // let data = ma::wma(data, 3.0, array![1.0, 2.0, 3.0], false); // println!("{:#}", data); let data = array![35,34,37,36,35]; let data = ma::wma(data, 5, true); println!("{:#}", data); } #[test] fn distance() { let data = maths::distance(30.658378, 104.065858, 30.572084, 104.064839, "m"); println!("{}", data); } #[test] fn distances() { let data = 4; let list = 5; println!("{:?}", data.max(list.clone())); } }