()
| 389 | |
| 390 | #[test] |
| 391 | fn variance() { |
| 392 | let (e, amount) = (1, 2); |
| 393 | let data = vec![ |
| 394 | TxData::add(1, ":amount", Number(5)), |
| 395 | TxData::add(2, ":amount", Number(10)), |
| 396 | TxData::add(2, ":amount", Number(10)), |
| 397 | TxData::add(1, ":amount", Number(2)), |
| 398 | TxData::add(1, ":amount", Number(4)), |
| 399 | TxData::add(1, ":amount", Number(6)), |
| 400 | ]; |
| 401 | |
| 402 | run_cases(vec![ |
| 403 | Case { |
| 404 | description: "[:find (variance ?amount) :where [?e :amount ?amount]]", |
| 405 | plan: Plan::Aggregate(Aggregate { |
| 406 | variables: vec![amount], |
| 407 | plan: Box::new(Plan::Project(Project { |
| 408 | variables: vec![amount], |
| 409 | plan: Box::new(Plan::MatchA(e, ":amount".to_string(), amount)), |
| 410 | })), |
| 411 | aggregation_fns: vec![AggregationFn::VARIANCE], |
| 412 | key_variables: vec![], |
| 413 | aggregation_variables: vec![amount], |
| 414 | with_variables: vec![], |
| 415 | }), |
| 416 | transactions: vec![data.clone()], |
| 417 | expectations: vec![vec![(vec![Rational32(Ratio::new(317, 36))], 0, 1)]], |
| 418 | // set-semantics |
| 419 | // expectations: vec![ |
| 420 | // vec![(vec![Rational32(Ratio::new(176, 25))], 0, 1)], |
| 421 | // ], |
| 422 | }, |
| 423 | Case { |
| 424 | description: "[:find ?e (variance ?amount) :where [?e :amount ?amount]]", |
| 425 | plan: Plan::Aggregate(Aggregate { |
| 426 | variables: vec![e, amount], |
| 427 | plan: Box::new(Plan::MatchA(e, ":amount".to_string(), amount)), |
| 428 | aggregation_fns: vec![AggregationFn::VARIANCE], |
| 429 | key_variables: vec![e], |
| 430 | aggregation_variables: vec![amount], |
| 431 | with_variables: vec![], |
| 432 | }), |
| 433 | transactions: vec![data.clone()], |
| 434 | expectations: vec![vec![ |
| 435 | (vec![Eid(1), Rational32(Ratio::new(35, 16))], 0, 1), |
| 436 | (vec![Eid(2), Rational32(Ratio::new(0, 1))], 0, 1), |
| 437 | ]], |
| 438 | }, |
| 439 | ]); |
| 440 | } |
| 441 | |
| 442 | #[test] |
| 443 | fn median() { |
nothing calls this directly
no test coverage detected