Merge pull request #49 from AlessandroBregoli/36-refactor-solve-the-warnings-issue

Solved all warnings
pull/51/head
Meliurwen 2 years ago committed by GitHub
commit eb0cf6e88d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/lib.rs
  2. 5
      src/parameter_learning.rs
  3. 2
      src/params.rs
  4. 1
      src/structure_learning/hypothesis_test.rs
  5. 4
      tests/parameter_learning.rs
  6. 4
      tests/params.rs
  7. 4
      tests/structure_learning.rs
  8. 2
      tests/tools.rs
  9. 7
      tests/utils.rs

@ -1,5 +1,5 @@
#![allow(non_snake_case)]
#[cfg(test)]
#[macro_use]
extern crate approx;
pub mod params;

@ -2,7 +2,6 @@ use crate::network;
use crate::params::*;
use crate::tools;
use ndarray::prelude::*;
use ndarray::{concatenate, Slice};
use std::collections::BTreeSet;
pub trait ParameterLearning{
@ -137,15 +136,13 @@ impl ParameterLearning for BayesianApproach {
node: usize,
parent_set: Option<BTreeSet<usize>>,
) -> Params {
//TODO: make this function general. Now it works only on ContinousTimeDiscreteState nodes
//Use parent_set from parameter if present. Otherwise use parent_set from network.
let parent_set = match parent_set {
Some(p) => p,
None => net.get_parent_set(node),
};
let (mut M, mut T) = sufficient_statistics(net, dataset, node.clone(), &parent_set);
let (M, T) = sufficient_statistics(net, dataset, node.clone(), &parent_set);
let alpha: f64 = self.alpha as f64 / M.shape()[0] as f64;
let tau: f64 = self.tau as f64 / M.shape()[0] as f64;

@ -1,7 +1,7 @@
use enum_dispatch::enum_dispatch;
use ndarray::prelude::*;
use rand::Rng;
use std::collections::{BTreeSet, HashMap};
use std::collections::{BTreeSet};
use thiserror::Error;
use rand_chacha::ChaCha8Rng;

@ -1,4 +1,3 @@
use ndarray::Array2;
use ndarray::Array3;
use ndarray::Axis;
use statrs::distribution::{ChiSquared, ContinuousCDF};

@ -1,3 +1,5 @@
#![allow(non_snake_case)]
mod utils;
use utils::*;
@ -6,9 +8,7 @@ use reCTBN::ctbn::*;
use reCTBN::network::Network;
use reCTBN::parameter_learning::*;
use reCTBN::{params, tools::*};
use std::collections::BTreeSet;
#[macro_use]
extern crate approx;
fn learn_binary_cim<T: ParameterLearning>(pl: T) {

@ -7,8 +7,8 @@ mod utils;
#[macro_use]
extern crate approx;
fn create_ternary_discrete_time_continous_param() -> DiscreteStatesContinousTimeParams {
#![allow(unused_must_use)]
let mut params = utils::generate_discrete_time_continous_params("A".to_string(), 3);
let cim = array![[[-3.0, 2.0, 1.0], [1.0, -5.0, 4.0], [2.3, 1.7, -4.0]]];
@ -25,6 +25,7 @@ fn test_get_label() {
#[test]
fn test_uniform_generation() {
#![allow(irrefutable_let_patterns)]
let param = create_ternary_discrete_time_continous_param();
let mut states = Array1::<usize>::zeros(10000);
@ -44,6 +45,7 @@ fn test_uniform_generation() {
#[test]
fn test_random_generation_state() {
#![allow(irrefutable_let_patterns)]
let param = create_ternary_discrete_time_continous_param();
let mut states = Array1::<usize>::zeros(10000);

@ -1,3 +1,5 @@
#![allow(non_snake_case)]
mod utils;
use utils::*;
@ -95,7 +97,7 @@ fn check_compatibility_between_dataset_and_network<T: StructureLearningAlgorithm
let _n1 = net
.add_node(generate_discrete_time_continous_node(String::from("n1"), 3))
.unwrap();
let net = sl.fit_transform(net, &data);
let _net = sl.fit_transform(net, &data);
}
#[test]

@ -3,7 +3,6 @@ use reCTBN::ctbn::*;
use reCTBN::network::Network;
use reCTBN::params;
use reCTBN::tools::*;
use std::collections::BTreeSet;
#[macro_use]
extern crate approx;
@ -12,6 +11,7 @@ mod utils;
#[test]
fn run_sampling() {
#![allow(unused_must_use)]
let mut net = CtbnNetwork::new();
let n1 = net
.add_node(utils::generate_discrete_time_continous_node(

@ -1,17 +1,12 @@
use reCTBN::params;
use std::collections::BTreeSet;
#[allow(dead_code)]
pub fn generate_discrete_time_continous_node(label: String, cardinality: usize) -> params::Params {
params::Params::DiscreteStatesContinousTime(generate_discrete_time_continous_params(label, cardinality))
}
pub fn generate_discrete_time_continous_params(label: String, cardinality: usize) -> params::DiscreteStatesContinousTimeParams{
let domain: BTreeSet<String> = (0..cardinality).map(|x| x.to_string()).collect();
params::DiscreteStatesContinousTimeParams::new(label, domain)
}

Loading…
Cancel
Save