diff --git a/Cargo.toml b/Cargo.toml index cc0aa33..2865eaf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,13 +9,16 @@ readme = "README.md" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[features] +progress_bar = ["dep:indicatif"] + [dependencies] serde_json = "1.0.115" hex = "0.4.3" npyz = "0.7.4" ndarray = "0.15.6" rayon = "1.10.0" -indicatif = "0.17.8" +indicatif = { version = "0.17.8", optional = true } ndarray-npy ="0.8.1" itertools = "0.12.1" thiserror = "1.0.58" @@ -24,6 +27,7 @@ thiserror = "1.0.58" criterion = "0.5.1" ndarray-rand = "0.14.0" anyhow = "1.0.81" +muscat = { path = ".", features = ["progress_bar"] } [[bench]] name = "cpa" diff --git a/src/util.rs b/src/util.rs index dc8316f..1b345fc 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,12 +1,16 @@ //! Convenient utility functions. -use std::{io::Read, path::Path, time::Duration}; +use std::{io::Read, path::Path}; -use indicatif::{ProgressBar, ProgressStyle}; use ndarray::{Array, Array1, Array2, ArrayView2}; use ndarray_npy::{read_npy, write_npy, ReadNpyError, ReadableElement, WriteNpyError}; use npyz::{Deserialize, NpyFile}; +#[cfg(feature = "progress_bar")] +use indicatif::{ProgressBar, ProgressStyle}; +#[cfg(feature = "progress_bar")] +use std::time::Duration; + /// Reads a [`NpyFile`] as a [`Array1`] /// /// This does the same as [`NpyFile.into_vec`] but faster, as this method reserves the resulting @@ -39,6 +43,7 @@ pub fn save_array< } /// Creates a [`ProgressBar`] with a predefined default style. +#[cfg(feature = "progress_bar")] pub fn progress_bar(len: usize) -> ProgressBar { let progress_bar = ProgressBar::new(len as u64).with_style( ProgressStyle::with_template("{elapsed_precise} {wide_bar} {pos}/{len} ({eta})").unwrap(),