Rename to from_array
This commit is contained in:
+4
-4
@@ -86,11 +86,11 @@ pub trait BaseVector<T: RealNumber>: Clone + Debug {
|
||||
/// Create a new vector from a &[T]
|
||||
/// ```
|
||||
/// use smartcore::linalg::naive::dense_matrix::*;
|
||||
/// let slice: &[f64] = &[0., 0.5, 2., 3., 4.];
|
||||
/// let a: Vec<f64> = BaseVector::from_slice(slice);
|
||||
/// assert_eq!(a, vec![0., 0.5, 2., 3., 4.]);
|
||||
/// let a: [f64; 5] = [0., 0.5, 2., 3., 4.];
|
||||
/// let v: Vec<f64> = BaseVector::from_array(&a);
|
||||
/// assert_eq!(v, vec![0., 0.5, 2., 3., 4.]);
|
||||
/// ```
|
||||
fn from_slice(f: &[T]) -> Self {
|
||||
fn from_array(f: &[T]) -> Self {
|
||||
let mut v = Self::zeros(f.len());
|
||||
for (i, elem) in f.iter().enumerate() {
|
||||
v.set(i, *elem);
|
||||
|
||||
@@ -58,7 +58,7 @@ impl<T: RealNumber, M: Matrix<T>, D: NBDistribution<T, M>> BaseNaiveBayes<T, M,
|
||||
*prediction
|
||||
})
|
||||
.collect::<Vec<T>>();
|
||||
let y_hat = M::RowVector::from_slice(&predictions);
|
||||
let y_hat = M::RowVector::from_array(&predictions);
|
||||
Ok(y_hat)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user