Skip to content

Commit

Permalink
Merge branch 'master' into cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kingofpayne authored Apr 19, 2024
2 parents 834562e + 6bde995 commit b5843bd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down
9 changes: 7 additions & 2 deletions src/util.rs
Original file line number Diff line number Diff line change
@@ -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, Axis};
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
Expand Down Expand Up @@ -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(),
Expand Down

0 comments on commit b5843bd

Please sign in to comment.