Skip to content

Commit

Permalink
Calculates correlations in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
cuducos committed May 9, 2024
1 parent ee0433c commit 0fbb5d4
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 1 deletion.
52 changes: 52 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ chrono = "0.4.38"
csv = "1.3.0"
pyo3 = { version = "0.18", features = ["abi3-py311"] }
rand = "0.8.5"
rayon = "1.10.0"
regex = "1.10.4"
walkdir = "2.5.0"

Expand Down
3 changes: 2 additions & 1 deletion src/whisky.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use anyhow::{anyhow, Result};
use csv::{ReaderBuilder, StringRecord};
use rand::seq::SliceRandom;
use rand::thread_rng;
use rayon::iter::{ParallelIterator, IntoParallelRefIterator};
use regex::Regex;

use crate::correlation::Correlation;
Expand Down Expand Up @@ -125,7 +126,7 @@ pub fn recommendations_for(name: String) -> Result<Vec<(PyWhisky, PyWhisky, f64)
}
let reference = whisky.ok_or(anyhow!("Whisky {} not found", name))?;
let mut correlations: Vec<Correlation> = others
.iter()
.par_iter()
.map(|w| Correlation::new(&reference, w))
.collect();

Expand Down

0 comments on commit 0fbb5d4

Please sign in to comment.