Skip to content

Commit

Permalink
[Rust] Add PyUserCF (#400)
Browse files Browse the repository at this point in the history
  • Loading branch information
massquantity authored Nov 9, 2023
1 parent 6519c9a commit f5c84f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
2 changes: 1 addition & 1 deletion rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ mod user_cf;
/// RecFarm module
#[pymodule]
fn recfarm(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<user_cf::UserCF>()?;
m.add_class::<user_cf::PyUserCF>()?;
Ok(())
}
9 changes: 4 additions & 5 deletions rust/src/user_cf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,8 @@ use rand::seq::SliceRandom;
use crate::similarities::{invert_cosine, sort_by_sims, SimOrd};
use crate::sparse::SparseMatrix;

// todo: PyUserCF
#[pyclass]
pub struct UserCF {
#[pyclass(module = "recfarm", name = "UserCF")]
pub struct PyUserCF {
task: String,
k_sim: usize,
n_users: usize,
Expand All @@ -27,7 +26,7 @@ pub struct UserCF {
}

#[pymethods]
impl UserCF {
impl PyUserCF {
#[new]
fn new(
task: &str,
Expand Down Expand Up @@ -56,7 +55,7 @@ impl UserCF {
data: item_sparse_data.extract::<Vec<f32>>()?,
};
let user_consumed = user_consumed.extract::<FxHashMap<i32, Vec<i32>>>()?;
Ok(UserCF {
Ok(Self {
task: task.to_string(),
k_sim,
n_users,
Expand Down

0 comments on commit f5c84f8

Please sign in to comment.