Skip to main content

pmcore/estimation/nonparametric/
mod.rs

1mod cycles;
2
3mod expansion;
4pub(crate) mod ipm;
5mod posterior;
6mod predictions;
7
8mod psi;
9pub(crate) mod qr;
10mod result;
11pub mod sampling;
12mod statistics;
13mod summaries;
14mod theta;
15mod weights;
16
17pub use cycles::{CycleLog, NPCycle};
18pub(crate) use expansion::adaptative_grid;
19pub use ipm::burke;
20pub use posterior::{posterior, Posterior};
21pub use predictions::{NPPredictionRow, NPPredictions};
22pub(crate) use psi::calculate_psi;
23pub use psi::Psi;
24pub use result::NonParametricResult;
25pub use statistics::{median, population_mean_median, posterior_mean_median, weighted_median};
26pub use summaries::{fit_summary, individual_summaries, population_summary};
27pub use theta::Theta;
28pub use weights::Weights;
29
30use std::path::Path;
31
32/// Create the parent directory of `path` if it has a non-empty one.
33///
34/// For a bare relative file name such as `theta.csv`, [`Path::parent`] returns
35/// `Some("")` (the empty path); calling `create_dir_all("")` would error. This
36/// helper skips that case so writing to the current directory works.
37pub(crate) fn create_parent_dir(path: &Path) -> std::io::Result<()> {
38    if let Some(parent) = path.parent() {
39        if !parent.as_os_str().is_empty() {
40            std::fs::create_dir_all(parent)?;
41        }
42    }
43    Ok(())
44}