causal-hub 0.0.5

A library for causal models, inference and discovery.
Documentation
use dry::macro_for;
use log::debug;
use paste::paste;

use crate::{
    io::JsonIO,
    models::{CatCTBN, GaussBN},
    types::Result,
};

macro_for!(
    $bn in [
        arth150, ecoli70, magic_irri, magic_niab
    ] {
    paste! {
        #[doc = "Load the `" $bn:upper "` Gaussian BN from the assets."]
        pub fn [<load_ $bn>]() -> Result<GaussBN> {
            // Log the loading of the BN.
            debug!("Loading the '{}' BN from assets.", stringify!($bn));
            // Read the JSON file and return the BN.
            GaussBN::from_json_string(include_str!(concat!(stringify!($bn), ".json")))
        }
    }
});

macro_for!(
    $ctbn in [
        eating
    ] {
    paste! {
        #[doc = "Load the `" $ctbn:upper "` categorical CTBN from the assets."]
        pub fn [<load_ $ctbn>]() -> Result<CatCTBN> {
            // Log the loading of the CTBN.
            debug!("Loading the '{}' CTBN from assets.", stringify!($ctbn));
            // Read the JSON file and return the CTBN.
            CatCTBN::from_json_string(include_str!(concat!(stringify!($ctbn), ".json")))
        }
    }
});