Fixed clippy warnings
This commit is contained in:
@@ -2,7 +2,7 @@ use std::error;
|
||||
use std::ffi::NulError;
|
||||
use std::fmt;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, Eq, PartialEq)]
|
||||
pub enum Error {
|
||||
Io,
|
||||
Parameter(String),
|
||||
|
||||
@@ -37,6 +37,12 @@ impl Matrix {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Matrix {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::Matrix;
|
||||
|
||||
@@ -70,24 +70,24 @@ impl Model {
|
||||
unsafe { std::slice::from_raw_parts((*self.model).q, (self.columns() * self.factors()) as usize) }
|
||||
}
|
||||
|
||||
pub fn p(&self, row_index: i32) -> Option<&[f32]>{
|
||||
pub fn p(&self, row_index: i32) -> Option<&[f32]> {
|
||||
if row_index >= 0 && row_index < self.rows() {
|
||||
let factors = self.factors();
|
||||
let start_index = factors as usize * row_index as usize;
|
||||
let end_index = factors as usize * (row_index as usize + 1);
|
||||
return Some(&self.p_factors()[start_index..end_index]);
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
|
||||
pub fn q(&self, column_index: i32) -> Option<&[f32]>{
|
||||
pub fn q(&self, column_index: i32) -> Option<&[f32]> {
|
||||
if column_index >= 0 && column_index < self.columns() {
|
||||
let factors = self.factors();
|
||||
let start_index = factors as usize * column_index as usize;
|
||||
let end_index = factors as usize * (column_index as usize + 1);
|
||||
return Some(&self.q_factors()[start_index..end_index]);
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
|
||||
pub fn rmse(&self, data: &Matrix) -> f64 {
|
||||
|
||||
Reference in New Issue
Block a user