Implement SVR and SVR kernels with Enum. Add tests for argsort_mut (#303)
* Add tests for argsort_mut * Add formatting and cleaning up .github directory * fix clippy error. suggestion to use .contains() * define type explicitly for variable jstack * Implement kernel as enumerator * basic svr and svr_params implementation * Complete enum implementation for Kernels. Implement search grid for SVR. Add documentation. * Fix serde configuration in cargo clippy * Implement search parameters (#304) * Implement SVR kernels as enumerator * basic svr and svr_params implementation * Implement search grid for SVR. Add documentation. * Fix serde configuration in cargo clippy * Fix wasm32 typetag * fix typetag * Bump to version 0.4.2
This commit is contained in:
@@ -619,7 +619,7 @@ pub trait MutArrayView1<T: Debug + Display + Copy + Sized>:
|
||||
T: Number + PartialOrd,
|
||||
{
|
||||
let stack_size = 64;
|
||||
let mut jstack = -1;
|
||||
let mut jstack: i32 = -1;
|
||||
let mut l = 0;
|
||||
let mut istack = vec![0; stack_size];
|
||||
let mut ir = self.shape() - 1;
|
||||
@@ -2190,4 +2190,29 @@ mod tests {
|
||||
|
||||
assert_eq!(result, [65, 581, 30])
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_argsort_mut_exact_boundary() {
|
||||
// Test index == length - 1 case
|
||||
let boundary =
|
||||
DenseMatrix::from_2d_array(&[&[1.0, 2.0, 3.0, f64::MAX], &[3.0, f64::MAX, 0.0, 2.0]])
|
||||
.unwrap();
|
||||
let mut view0: Vec<f64> = boundary.get_col(0).iterator(0).copied().collect();
|
||||
let indices = view0.argsort_mut();
|
||||
assert_eq!(indices.last(), Some(&1));
|
||||
assert_eq!(indices.first(), Some(&0));
|
||||
|
||||
let mut view1: Vec<f64> = boundary.get_col(3).iterator(0).copied().collect();
|
||||
let indices = view1.argsort_mut();
|
||||
assert_eq!(indices.last(), Some(&0));
|
||||
assert_eq!(indices.first(), Some(&1));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_argsort_mut_filled_array() {
|
||||
let matrix = DenseMatrix::<f64>::rand(1000, 1000);
|
||||
let mut view: Vec<f64> = matrix.get_col(0).iterator(0).copied().collect();
|
||||
let sorted = view.argsort_mut();
|
||||
assert_eq!(sorted.len(), 1000);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user