Merge branch 'development' of github.com:smartcorelib/smartcore into development
This commit is contained in:
@@ -19,6 +19,7 @@ jobs:
|
|||||||
{ os: "ubuntu", target: "i686-unknown-linux-gnu" },
|
{ os: "ubuntu", target: "i686-unknown-linux-gnu" },
|
||||||
{ os: "ubuntu", target: "wasm32-unknown-unknown" },
|
{ os: "ubuntu", target: "wasm32-unknown-unknown" },
|
||||||
{ os: "macos", target: "aarch64-apple-darwin" },
|
{ os: "macos", target: "aarch64-apple-darwin" },
|
||||||
|
{ os: "ubuntu", target: "wasm32-wasi" },
|
||||||
]
|
]
|
||||||
env:
|
env:
|
||||||
TZ: "/usr/share/zoneinfo/your/location"
|
TZ: "/usr/share/zoneinfo/your/location"
|
||||||
@@ -42,6 +43,9 @@ jobs:
|
|||||||
- name: Install test runner for wasm
|
- name: Install test runner for wasm
|
||||||
if: matrix.platform.target == 'wasm32-unknown-unknown'
|
if: matrix.platform.target == 'wasm32-unknown-unknown'
|
||||||
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
|
||||||
|
- name: Install test runner for wasi
|
||||||
|
if: matrix.platform.target == 'wasm32-wasi'
|
||||||
|
run: curl https://wasmtime.dev/install.sh -sSf | bash
|
||||||
- name: Stable Build
|
- name: Stable Build
|
||||||
uses: actions-rs/cargo@v1
|
uses: actions-rs/cargo@v1
|
||||||
with:
|
with:
|
||||||
@@ -56,6 +60,12 @@ jobs:
|
|||||||
- name: Tests in WASM
|
- name: Tests in WASM
|
||||||
if: matrix.platform.target == 'wasm32-unknown-unknown'
|
if: matrix.platform.target == 'wasm32-unknown-unknown'
|
||||||
run: wasm-pack test --node -- --all-features
|
run: wasm-pack test --node -- --all-features
|
||||||
|
- name: Tests in WASI
|
||||||
|
if: matrix.platform.target == 'wasm32-wasi'
|
||||||
|
run: |
|
||||||
|
export WASMTIME_HOME="$HOME/.wasmtime"
|
||||||
|
export PATH="$WASMTIME_HOME/bin:$PATH"
|
||||||
|
cargo install cargo-wasi && cargo wasi test
|
||||||
|
|
||||||
check_features:
|
check_features:
|
||||||
runs-on: "${{ matrix.platform.os }}-latest"
|
runs-on: "${{ matrix.platform.os }}-latest"
|
||||||
|
|||||||
+4
-1
@@ -40,9 +40,12 @@ criterion = { version = "0.4", default-features = false }
|
|||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
bincode = "1.3.1"
|
bincode = "1.3.1"
|
||||||
|
|
||||||
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
|
[target.'cfg(all(target_arch = "wasm32", not(target_os = "wasi")))'.dev-dependencies]
|
||||||
wasm-bindgen-test = "0.3"
|
wasm-bindgen-test = "0.3"
|
||||||
|
|
||||||
|
[workspace]
|
||||||
|
resolver = "2"
|
||||||
|
|
||||||
[profile.test]
|
[profile.test]
|
||||||
debug = 1
|
debug = 1
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|||||||
@@ -316,7 +316,10 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::linalg::basic::matrix::DenseMatrix;
|
use crate::linalg::basic::matrix::DenseMatrix;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn bbdtree_iris() {
|
fn bbdtree_iris() {
|
||||||
let data = DenseMatrix::from_2d_array(&[
|
let data = DenseMatrix::from_2d_array(&[
|
||||||
|
|||||||
@@ -468,7 +468,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn cover_tree_test() {
|
fn cover_tree_test() {
|
||||||
let data = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
|
let data = vec![1, 2, 3, 4, 5, 6, 7, 8, 9];
|
||||||
@@ -485,7 +488,10 @@ mod tests {
|
|||||||
let knn: Vec<i32> = knn.iter().map(|v| *v.2).collect();
|
let knn: Vec<i32> = knn.iter().map(|v| *v.2).collect();
|
||||||
assert_eq!(vec!(3, 4, 5, 6, 7), knn);
|
assert_eq!(vec!(3, 4, 5, 6, 7), knn);
|
||||||
}
|
}
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn cover_tree_test1() {
|
fn cover_tree_test1() {
|
||||||
let data = vec![
|
let data = vec![
|
||||||
@@ -504,7 +510,10 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(vec!(0, 1, 2), knn);
|
assert_eq!(vec!(0, 1, 2), knn);
|
||||||
}
|
}
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn serde() {
|
fn serde() {
|
||||||
|
|||||||
@@ -143,7 +143,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn knn_find() {
|
fn knn_find() {
|
||||||
let data1 = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
let data1 = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
|
||||||
@@ -190,7 +193,10 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(vec!(1, 2, 3), found_idxs2);
|
assert_eq!(vec!(1, 2, 3), found_idxs2);
|
||||||
}
|
}
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn knn_point_eq() {
|
fn knn_point_eq() {
|
||||||
let point1 = KNNPoint {
|
let point1 = KNNPoint {
|
||||||
|
|||||||
@@ -95,14 +95,20 @@ impl<T: PartialOrd + Debug> HeapSelection<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn with_capacity() {
|
fn with_capacity() {
|
||||||
let heap = HeapSelection::<i32>::with_capacity(3);
|
let heap = HeapSelection::<i32>::with_capacity(3);
|
||||||
assert_eq!(3, heap.k);
|
assert_eq!(3, heap.k);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_add() {
|
fn test_add() {
|
||||||
let mut heap = HeapSelection::with_capacity(3);
|
let mut heap = HeapSelection::with_capacity(3);
|
||||||
@@ -120,7 +126,10 @@ mod tests {
|
|||||||
assert_eq!(vec![2, 0, -5], heap.get());
|
assert_eq!(vec![2, 0, -5], heap.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_add1() {
|
fn test_add1() {
|
||||||
let mut heap = HeapSelection::with_capacity(3);
|
let mut heap = HeapSelection::with_capacity(3);
|
||||||
@@ -135,7 +144,10 @@ mod tests {
|
|||||||
assert_eq!(vec![0f64, -1f64, -5f64], heap.get());
|
assert_eq!(vec![0f64, -1f64, -5f64], heap.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_add2() {
|
fn test_add2() {
|
||||||
let mut heap = HeapSelection::with_capacity(3);
|
let mut heap = HeapSelection::with_capacity(3);
|
||||||
@@ -148,7 +160,10 @@ mod tests {
|
|||||||
assert_eq!(vec![5.6568, 2.8284, 0.0], heap.get());
|
assert_eq!(vec![5.6568, 2.8284, 0.0], heap.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_add_ordered() {
|
fn test_add_ordered() {
|
||||||
let mut heap = HeapSelection::with_capacity(3);
|
let mut heap = HeapSelection::with_capacity(3);
|
||||||
|
|||||||
@@ -113,7 +113,10 @@ impl<T: Num + PartialOrd + Copy> QuickArgSort for Vec<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn with_capacity() {
|
fn with_capacity() {
|
||||||
let arr1 = vec![0.3, 0.1, 0.2, 0.4, 0.9, 0.5, 0.7, 0.6, 0.8];
|
let arr1 = vec![0.3, 0.1, 0.2, 0.4, 0.9, 0.5, 0.7, 0.6, 0.8];
|
||||||
|
|||||||
+11
-3
@@ -425,7 +425,10 @@ mod tests {
|
|||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn fit_predict_dbscan() {
|
fn fit_predict_dbscan() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -457,7 +460,10 @@ mod tests {
|
|||||||
assert_eq!(expected_labels, predicted_labels);
|
assert_eq!(expected_labels, predicted_labels);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn serde() {
|
fn serde() {
|
||||||
@@ -491,10 +497,12 @@ mod tests {
|
|||||||
|
|
||||||
assert_eq!(dbscan, deserialized_dbscan);
|
assert_eq!(dbscan, deserialized_dbscan);
|
||||||
}
|
}
|
||||||
use crate::dataset::generator;
|
|
||||||
|
|
||||||
|
#[cfg(feature = "datasets")]
|
||||||
#[test]
|
#[test]
|
||||||
fn from_vec() {
|
fn from_vec() {
|
||||||
|
use crate::dataset::generator;
|
||||||
|
|
||||||
// Generate three blobs
|
// Generate three blobs
|
||||||
let blobs = generator::make_blobs(100, 2, 3);
|
let blobs = generator::make_blobs(100, 2, 3);
|
||||||
let x: DenseMatrix<f32> = DenseMatrix::from_iterator(blobs.data.into_iter(), 100, 2, 0);
|
let x: DenseMatrix<f32> = DenseMatrix::from_iterator(blobs.data.into_iter(), 100, 2, 0);
|
||||||
|
|||||||
+12
-3
@@ -418,7 +418,10 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::linalg::basic::matrix::DenseMatrix;
|
use crate::linalg::basic::matrix::DenseMatrix;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn invalid_k() {
|
fn invalid_k() {
|
||||||
let x = DenseMatrix::from_2d_array(&[&[1, 2, 3], &[4, 5, 6]]);
|
let x = DenseMatrix::from_2d_array(&[&[1, 2, 3], &[4, 5, 6]]);
|
||||||
@@ -462,7 +465,10 @@ mod tests {
|
|||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn fit_predict_iris() {
|
fn fit_predict_iris() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -497,7 +503,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn serde() {
|
fn serde() {
|
||||||
|
|||||||
@@ -69,7 +69,10 @@ mod tests {
|
|||||||
assert!(serialize_data(&dataset, "boston.xy").is_ok());
|
assert!(serialize_data(&dataset, "boston.xy").is_ok());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn boston_dataset() {
|
fn boston_dataset() {
|
||||||
let dataset = load_dataset();
|
let dataset = load_dataset();
|
||||||
|
|||||||
@@ -83,7 +83,10 @@ mod tests {
|
|||||||
// assert!(serialize_data(&dataset, "breast_cancer.xy").is_ok());
|
// assert!(serialize_data(&dataset, "breast_cancer.xy").is_ok());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn cancer_dataset() {
|
fn cancer_dataset() {
|
||||||
let dataset = load_dataset();
|
let dataset = load_dataset();
|
||||||
|
|||||||
@@ -67,7 +67,10 @@ mod tests {
|
|||||||
// assert!(serialize_data(&dataset, "diabetes.xy").is_ok());
|
// assert!(serialize_data(&dataset, "diabetes.xy").is_ok());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn boston_dataset() {
|
fn boston_dataset() {
|
||||||
let dataset = load_dataset();
|
let dataset = load_dataset();
|
||||||
|
|||||||
@@ -57,7 +57,10 @@ mod tests {
|
|||||||
let dataset = load_dataset();
|
let dataset = load_dataset();
|
||||||
assert!(serialize_data(&dataset, "digits.xy").is_ok());
|
assert!(serialize_data(&dataset, "digits.xy").is_ok());
|
||||||
}
|
}
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn digits_dataset() {
|
fn digits_dataset() {
|
||||||
let dataset = load_dataset();
|
let dataset = load_dataset();
|
||||||
|
|||||||
@@ -137,7 +137,10 @@ mod tests {
|
|||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_make_blobs() {
|
fn test_make_blobs() {
|
||||||
let dataset = make_blobs(10, 2, 3);
|
let dataset = make_blobs(10, 2, 3);
|
||||||
@@ -150,7 +153,10 @@ mod tests {
|
|||||||
assert_eq!(dataset.num_samples, 10);
|
assert_eq!(dataset.num_samples, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_make_circles() {
|
fn test_make_circles() {
|
||||||
let dataset = make_circles(10, 0.5, 0.05);
|
let dataset = make_circles(10, 0.5, 0.05);
|
||||||
@@ -163,7 +169,10 @@ mod tests {
|
|||||||
assert_eq!(dataset.num_samples, 10);
|
assert_eq!(dataset.num_samples, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_make_moons() {
|
fn test_make_moons() {
|
||||||
let dataset = make_moons(10, 0.05);
|
let dataset = make_moons(10, 0.05);
|
||||||
|
|||||||
+4
-1
@@ -70,7 +70,10 @@ mod tests {
|
|||||||
// assert!(serialize_data(&dataset, "iris.xy").is_ok());
|
// assert!(serialize_data(&dataset, "iris.xy").is_ok());
|
||||||
// }
|
// }
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn iris_dataset() {
|
fn iris_dataset() {
|
||||||
let dataset = load_dataset();
|
let dataset = load_dataset();
|
||||||
|
|||||||
+4
-1
@@ -121,7 +121,10 @@ pub(crate) fn deserialize_data(
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn as_matrix() {
|
fn as_matrix() {
|
||||||
let dataset = Dataset {
|
let dataset = Dataset {
|
||||||
|
|||||||
@@ -446,7 +446,10 @@ mod tests {
|
|||||||
&[6.8, 161.0, 60.0, 15.6],
|
&[6.8, 161.0, 60.0, 15.6],
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn pca_components() {
|
fn pca_components() {
|
||||||
let us_arrests = us_arrests_data();
|
let us_arrests = us_arrests_data();
|
||||||
@@ -466,7 +469,10 @@ mod tests {
|
|||||||
epsilon = 1e-3
|
epsilon = 1e-3
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn decompose_covariance() {
|
fn decompose_covariance() {
|
||||||
let us_arrests = us_arrests_data();
|
let us_arrests = us_arrests_data();
|
||||||
@@ -579,7 +585,10 @@ mod tests {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn decompose_correlation() {
|
fn decompose_correlation() {
|
||||||
let us_arrests = us_arrests_data();
|
let us_arrests = us_arrests_data();
|
||||||
@@ -700,7 +709,7 @@ mod tests {
|
|||||||
|
|
||||||
// Disable this test for now
|
// Disable this test for now
|
||||||
// TODO: implement deserialization for new DenseMatrix
|
// TODO: implement deserialization for new DenseMatrix
|
||||||
// #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
// #[cfg_attr(all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test::wasm_bindgen_test)]
|
||||||
// #[test]
|
// #[test]
|
||||||
// #[cfg(feature = "serde")]
|
// #[cfg(feature = "serde")]
|
||||||
// fn pca_serde() {
|
// fn pca_serde() {
|
||||||
|
|||||||
@@ -237,7 +237,10 @@ mod tests {
|
|||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn svd_decompose() {
|
fn svd_decompose() {
|
||||||
// https://stat.ethz.ch/R-manual/R-devel/library/datasets/html/USArrests.html
|
// https://stat.ethz.ch/R-manual/R-devel/library/datasets/html/USArrests.html
|
||||||
@@ -316,7 +319,7 @@ mod tests {
|
|||||||
|
|
||||||
// Disable this test for now
|
// Disable this test for now
|
||||||
// TODO: implement deserialization for new DenseMatrix
|
// TODO: implement deserialization for new DenseMatrix
|
||||||
// #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
// #[cfg_attr(all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test::wasm_bindgen_test)]
|
||||||
// #[test]
|
// #[test]
|
||||||
// #[cfg(feature = "serde")]
|
// #[cfg(feature = "serde")]
|
||||||
// fn serde() {
|
// fn serde() {
|
||||||
|
|||||||
@@ -632,7 +632,10 @@ mod tests {
|
|||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn fit_predict_iris() {
|
fn fit_predict_iris() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -678,7 +681,10 @@ mod tests {
|
|||||||
assert!(accuracy(&y, &classifier.predict(&x).unwrap()) >= 0.95);
|
assert!(accuracy(&y, &classifier.predict(&x).unwrap()) >= 0.95);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn fit_predict_iris_oob() {
|
fn fit_predict_iris_oob() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -727,7 +733,10 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn serde() {
|
fn serde() {
|
||||||
|
|||||||
@@ -550,7 +550,10 @@ mod tests {
|
|||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn fit_longley() {
|
fn fit_longley() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -595,7 +598,10 @@ mod tests {
|
|||||||
assert!(mean_absolute_error(&y, &y_hat) < 1.0);
|
assert!(mean_absolute_error(&y, &y_hat) < 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn fit_predict_longley_oob() {
|
fn fit_predict_longley_oob() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -645,7 +651,10 @@ mod tests {
|
|||||||
assert!(mean_absolute_error(&y, &y_hat) < mean_absolute_error(&y, &y_hat_oob));
|
assert!(mean_absolute_error(&y, &y_hat) < mean_absolute_error(&y, &y_hat_oob));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn serde() {
|
fn serde() {
|
||||||
|
|||||||
@@ -169,7 +169,10 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::linalg::basic::matrix::DenseMatrix;
|
use crate::linalg::basic::matrix::DenseMatrix;
|
||||||
use approx::relative_eq;
|
use approx::relative_eq;
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn cholesky_decompose() {
|
fn cholesky_decompose() {
|
||||||
let a = DenseMatrix::from_2d_array(&[&[25., 15., -5.], &[15., 18., 0.], &[-5., 0., 11.]]);
|
let a = DenseMatrix::from_2d_array(&[&[25., 15., -5.], &[15., 18., 0.], &[-5., 0., 11.]]);
|
||||||
@@ -188,7 +191,10 @@ mod tests {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn cholesky_solve_mut() {
|
fn cholesky_solve_mut() {
|
||||||
let a = DenseMatrix::from_2d_array(&[&[25., 15., -5.], &[15., 18., 0.], &[-5., 0., 11.]]);
|
let a = DenseMatrix::from_2d_array(&[&[25., 15., -5.], &[15., 18., 0.], &[-5., 0., 11.]]);
|
||||||
|
|||||||
@@ -810,7 +810,10 @@ mod tests {
|
|||||||
use crate::linalg::basic::matrix::DenseMatrix;
|
use crate::linalg::basic::matrix::DenseMatrix;
|
||||||
use approx::relative_eq;
|
use approx::relative_eq;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn decompose_symmetric() {
|
fn decompose_symmetric() {
|
||||||
let A = DenseMatrix::from_2d_array(&[
|
let A = DenseMatrix::from_2d_array(&[
|
||||||
@@ -841,7 +844,10 @@ mod tests {
|
|||||||
assert!((0f64 - evd.e[i]).abs() < std::f64::EPSILON);
|
assert!((0f64 - evd.e[i]).abs() < std::f64::EPSILON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn decompose_asymmetric() {
|
fn decompose_asymmetric() {
|
||||||
let A = DenseMatrix::from_2d_array(&[
|
let A = DenseMatrix::from_2d_array(&[
|
||||||
@@ -872,7 +878,10 @@ mod tests {
|
|||||||
assert!((0f64 - evd.e[i]).abs() < std::f64::EPSILON);
|
assert!((0f64 - evd.e[i]).abs() < std::f64::EPSILON);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn decompose_complex() {
|
fn decompose_complex() {
|
||||||
let A = DenseMatrix::from_2d_array(&[
|
let A = DenseMatrix::from_2d_array(&[
|
||||||
|
|||||||
@@ -260,7 +260,10 @@ mod tests {
|
|||||||
use crate::linalg::basic::matrix::DenseMatrix;
|
use crate::linalg::basic::matrix::DenseMatrix;
|
||||||
use approx::relative_eq;
|
use approx::relative_eq;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn decompose() {
|
fn decompose() {
|
||||||
let a = DenseMatrix::from_2d_array(&[&[1., 2., 3.], &[0., 1., 5.], &[5., 6., 0.]]);
|
let a = DenseMatrix::from_2d_array(&[&[1., 2., 3.], &[0., 1., 5.], &[5., 6., 0.]]);
|
||||||
@@ -275,7 +278,10 @@ mod tests {
|
|||||||
assert!(relative_eq!(lu.U(), expected_U, epsilon = 1e-4));
|
assert!(relative_eq!(lu.U(), expected_U, epsilon = 1e-4));
|
||||||
assert!(relative_eq!(lu.pivot(), expected_pivot, epsilon = 1e-4));
|
assert!(relative_eq!(lu.pivot(), expected_pivot, epsilon = 1e-4));
|
||||||
}
|
}
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn inverse() {
|
fn inverse() {
|
||||||
let a = DenseMatrix::from_2d_array(&[&[1., 2., 3.], &[0., 1., 5.], &[5., 6., 0.]]);
|
let a = DenseMatrix::from_2d_array(&[&[1., 2., 3.], &[0., 1., 5.], &[5., 6., 0.]]);
|
||||||
|
|||||||
@@ -198,7 +198,10 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::linalg::basic::matrix::DenseMatrix;
|
use crate::linalg::basic::matrix::DenseMatrix;
|
||||||
use approx::relative_eq;
|
use approx::relative_eq;
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn decompose() {
|
fn decompose() {
|
||||||
let a = DenseMatrix::from_2d_array(&[&[0.9, 0.4, 0.7], &[0.4, 0.5, 0.3], &[0.7, 0.3, 0.8]]);
|
let a = DenseMatrix::from_2d_array(&[&[0.9, 0.4, 0.7], &[0.4, 0.5, 0.3], &[0.7, 0.3, 0.8]]);
|
||||||
@@ -217,7 +220,10 @@ mod tests {
|
|||||||
assert!(relative_eq!(qr.R().abs(), r.abs(), epsilon = 1e-4));
|
assert!(relative_eq!(qr.R().abs(), r.abs(), epsilon = 1e-4));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn qr_solve_mut() {
|
fn qr_solve_mut() {
|
||||||
let a = DenseMatrix::from_2d_array(&[&[0.9, 0.4, 0.7], &[0.4, 0.5, 0.3], &[0.7, 0.3, 0.8]]);
|
let a = DenseMatrix::from_2d_array(&[&[0.9, 0.4, 0.7], &[0.4, 0.5, 0.3], &[0.7, 0.3, 0.8]]);
|
||||||
|
|||||||
@@ -479,7 +479,10 @@ mod tests {
|
|||||||
use crate::linalg::basic::matrix::DenseMatrix;
|
use crate::linalg::basic::matrix::DenseMatrix;
|
||||||
use approx::relative_eq;
|
use approx::relative_eq;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn decompose_symmetric() {
|
fn decompose_symmetric() {
|
||||||
let A = DenseMatrix::from_2d_array(&[
|
let A = DenseMatrix::from_2d_array(&[
|
||||||
@@ -510,7 +513,10 @@ mod tests {
|
|||||||
assert!((s[i] - svd.s[i]).abs() < 1e-4);
|
assert!((s[i] - svd.s[i]).abs() < 1e-4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn decompose_asymmetric() {
|
fn decompose_asymmetric() {
|
||||||
let A = DenseMatrix::from_2d_array(&[
|
let A = DenseMatrix::from_2d_array(&[
|
||||||
@@ -711,7 +717,10 @@ mod tests {
|
|||||||
assert!((s[i] - svd.s[i]).abs() < 1e-4);
|
assert!((s[i] - svd.s[i]).abs() < 1e-4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn solve() {
|
fn solve() {
|
||||||
let a = DenseMatrix::from_2d_array(&[&[0.9, 0.4, 0.7], &[0.4, 0.5, 0.3], &[0.7, 0.3, 0.8]]);
|
let a = DenseMatrix::from_2d_array(&[&[0.9, 0.4, 0.7], &[0.4, 0.5, 0.3], &[0.7, 0.3, 0.8]]);
|
||||||
@@ -722,7 +731,10 @@ mod tests {
|
|||||||
assert!(relative_eq!(w, expected_w, epsilon = 1e-2));
|
assert!(relative_eq!(w, expected_w, epsilon = 1e-2));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn decompose_restore() {
|
fn decompose_restore() {
|
||||||
let a = DenseMatrix::from_2d_array(&[&[1.0, 2.0, 3.0, 4.0], &[5.0, 6.0, 7.0, 8.0]]);
|
let a = DenseMatrix::from_2d_array(&[&[1.0, 2.0, 3.0, 4.0], &[5.0, 6.0, 7.0, 8.0]]);
|
||||||
|
|||||||
@@ -491,7 +491,10 @@ mod tests {
|
|||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn elasticnet_longley() {
|
fn elasticnet_longley() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -535,7 +538,10 @@ mod tests {
|
|||||||
assert!(mean_absolute_error(&y_hat, &y) < 30.0);
|
assert!(mean_absolute_error(&y_hat, &y) < 30.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn elasticnet_fit_predict1() {
|
fn elasticnet_fit_predict1() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -603,7 +609,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: serialization for the new DenseMatrix needs to be implemented
|
// TODO: serialization for the new DenseMatrix needs to be implemented
|
||||||
// #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
// #[cfg_attr(all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test::wasm_bindgen_test)]
|
||||||
// #[test]
|
// #[test]
|
||||||
// #[cfg(feature = "serde")]
|
// #[cfg(feature = "serde")]
|
||||||
// fn serde() {
|
// fn serde() {
|
||||||
|
|||||||
+5
-2
@@ -398,7 +398,10 @@ mod tests {
|
|||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn lasso_fit_predict() {
|
fn lasso_fit_predict() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -448,7 +451,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: serialization for the new DenseMatrix needs to be implemented
|
// TODO: serialization for the new DenseMatrix needs to be implemented
|
||||||
// #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
// #[cfg_attr(all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test::wasm_bindgen_test)]
|
||||||
// #[test]
|
// #[test]
|
||||||
// #[cfg(feature = "serde")]
|
// #[cfg(feature = "serde")]
|
||||||
// fn serde() {
|
// fn serde() {
|
||||||
|
|||||||
@@ -325,7 +325,10 @@ mod tests {
|
|||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn ols_fit_predict() {
|
fn ols_fit_predict() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -372,7 +375,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: serialization for the new DenseMatrix needs to be implemented
|
// TODO: serialization for the new DenseMatrix needs to be implemented
|
||||||
// #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
// #[cfg_attr(all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test::wasm_bindgen_test)]
|
||||||
// #[test]
|
// #[test]
|
||||||
// #[cfg(feature = "serde")]
|
// #[cfg(feature = "serde")]
|
||||||
// fn serde() {
|
// fn serde() {
|
||||||
|
|||||||
@@ -577,6 +577,8 @@ impl<TX: Number + FloatNumber + RealNumber, TY: Number + Ord, X: Array2<TX>, Y:
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
|
#[cfg(feature = "datasets")]
|
||||||
use crate::dataset::generator::make_blobs;
|
use crate::dataset::generator::make_blobs;
|
||||||
use crate::linalg::basic::arrays::Array;
|
use crate::linalg::basic::arrays::Array;
|
||||||
use crate::linalg::basic::matrix::DenseMatrix;
|
use crate::linalg::basic::matrix::DenseMatrix;
|
||||||
@@ -596,7 +598,10 @@ mod tests {
|
|||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn multiclass_objective_f() {
|
fn multiclass_objective_f() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -653,7 +658,10 @@ mod tests {
|
|||||||
assert!((g[0].abs() - 32.0).abs() < 1e-4);
|
assert!((g[0].abs() - 32.0).abs() < 1e-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn binary_objective_f() {
|
fn binary_objective_f() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -712,7 +720,10 @@ mod tests {
|
|||||||
assert!((g[2] - 3.8693).abs() < 1e-4);
|
assert!((g[2] - 3.8693).abs() < 1e-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn lr_fit_predict() {
|
fn lr_fit_predict() {
|
||||||
let x: DenseMatrix<f64> = DenseMatrix::from_2d_array(&[
|
let x: DenseMatrix<f64> = DenseMatrix::from_2d_array(&[
|
||||||
@@ -751,7 +762,11 @@ mod tests {
|
|||||||
assert_eq!(y_hat, vec![0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]);
|
assert_eq!(y_hat, vec![0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg(feature = "datasets")]
|
||||||
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn lr_fit_predict_multiclass() {
|
fn lr_fit_predict_multiclass() {
|
||||||
let blobs = make_blobs(15, 4, 3);
|
let blobs = make_blobs(15, 4, 3);
|
||||||
@@ -778,7 +793,11 @@ mod tests {
|
|||||||
assert!(reg_coeff_sum < coeff);
|
assert!(reg_coeff_sum < coeff);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg(feature = "datasets")]
|
||||||
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn lr_fit_predict_binary() {
|
fn lr_fit_predict_binary() {
|
||||||
let blobs = make_blobs(20, 4, 2);
|
let blobs = make_blobs(20, 4, 2);
|
||||||
@@ -809,7 +828,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: serialization for the new DenseMatrix needs to be implemented
|
// TODO: serialization for the new DenseMatrix needs to be implemented
|
||||||
// #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
// #[cfg_attr(all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test::wasm_bindgen_test)]
|
||||||
// #[test]
|
// #[test]
|
||||||
// #[cfg(feature = "serde")]
|
// #[cfg(feature = "serde")]
|
||||||
// fn serde() {
|
// fn serde() {
|
||||||
@@ -840,7 +859,10 @@ mod tests {
|
|||||||
// assert_eq!(lr, deserialized_lr);
|
// assert_eq!(lr, deserialized_lr);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn lr_fit_predict_iris() {
|
fn lr_fit_predict_iris() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
|
|||||||
@@ -443,7 +443,10 @@ mod tests {
|
|||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn ridge_fit_predict() {
|
fn ridge_fit_predict() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -500,7 +503,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: implement serialization for new DenseMatrix
|
// TODO: implement serialization for new DenseMatrix
|
||||||
// #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
// #[cfg_attr(all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test::wasm_bindgen_test)]
|
||||||
// #[test]
|
// #[test]
|
||||||
// #[cfg(feature = "serde")]
|
// #[cfg(feature = "serde")]
|
||||||
// fn serde() {
|
// fn serde() {
|
||||||
|
|||||||
@@ -83,7 +83,10 @@ impl<T: Number> Metrics<T> for Accuracy<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn accuracy_float() {
|
fn accuracy_float() {
|
||||||
let y_pred: Vec<f64> = vec![0., 2., 1., 3.];
|
let y_pred: Vec<f64> = vec![0., 2., 1., 3.];
|
||||||
@@ -96,7 +99,10 @@ mod tests {
|
|||||||
assert!((score2 - 1.0).abs() < 1e-8);
|
assert!((score2 - 1.0).abs() < 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn accuracy_int() {
|
fn accuracy_int() {
|
||||||
let y_pred: Vec<i32> = vec![0, 2, 1, 3];
|
let y_pred: Vec<i32> = vec![0, 2, 1, 3];
|
||||||
|
|||||||
+4
-1
@@ -113,7 +113,10 @@ impl<T: FloatNumber + PartialOrd> Metrics<T> for AUC<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn auc() {
|
fn auc() {
|
||||||
let y_true: Vec<f64> = vec![0., 0., 1., 1.];
|
let y_true: Vec<f64> = vec![0., 0., 1., 1.];
|
||||||
|
|||||||
@@ -87,7 +87,10 @@ impl<T: Number + Ord> Metrics<T> for HCVScore<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn homogeneity_score() {
|
fn homogeneity_score() {
|
||||||
let v1 = vec![0, 0, 1, 1, 2, 0, 4];
|
let v1 = vec![0, 0, 1, 1, 2, 0, 4];
|
||||||
|
|||||||
@@ -102,7 +102,10 @@ pub fn mutual_info_score(contingency: &[Vec<usize>]) -> f64 {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn contingency_matrix_test() {
|
fn contingency_matrix_test() {
|
||||||
let v1 = vec![0, 0, 1, 1, 2, 0, 4];
|
let v1 = vec![0, 0, 1, 1, 2, 0, 4];
|
||||||
@@ -114,7 +117,10 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn entropy_test() {
|
fn entropy_test() {
|
||||||
let v1 = vec![0, 0, 1, 1, 2, 0, 4];
|
let v1 = vec![0, 0, 1, 1, 2, 0, 4];
|
||||||
@@ -122,7 +128,10 @@ mod tests {
|
|||||||
assert!((1.2770 - entropy(&v1).unwrap() as f64).abs() < 1e-4);
|
assert!((1.2770 - entropy(&v1).unwrap() as f64).abs() < 1e-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn mutual_info_score_test() {
|
fn mutual_info_score_test() {
|
||||||
let v1 = vec![0, 0, 1, 1, 2, 0, 4];
|
let v1 = vec![0, 0, 1, 1, 2, 0, 4];
|
||||||
|
|||||||
@@ -76,7 +76,10 @@ impl<T: Number, A: ArrayView1<T>> Distance<A> for Euclidian<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn squared_distance() {
|
fn squared_distance() {
|
||||||
let a = vec![1, 2, 3];
|
let a = vec![1, 2, 3];
|
||||||
|
|||||||
@@ -70,7 +70,10 @@ impl<T: Number, A: ArrayView1<T>> Distance<A> for Hamming<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn hamming_distance() {
|
fn hamming_distance() {
|
||||||
let a = vec![1, 0, 0, 1, 0, 0, 1];
|
let a = vec![1, 0, 0, 1, 0, 0, 1];
|
||||||
|
|||||||
@@ -139,7 +139,10 @@ mod tests {
|
|||||||
use crate::linalg::basic::arrays::ArrayView2;
|
use crate::linalg::basic::arrays::ArrayView2;
|
||||||
use crate::linalg::basic::matrix::DenseMatrix;
|
use crate::linalg::basic::matrix::DenseMatrix;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn mahalanobis_distance() {
|
fn mahalanobis_distance() {
|
||||||
let data = DenseMatrix::from_2d_array(&[
|
let data = DenseMatrix::from_2d_array(&[
|
||||||
|
|||||||
@@ -66,7 +66,10 @@ impl<T: Number, A: ArrayView1<T>> Distance<A> for Manhattan<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn manhattan_distance() {
|
fn manhattan_distance() {
|
||||||
let a = vec![1., 2., 3.];
|
let a = vec![1., 2., 3.];
|
||||||
|
|||||||
@@ -71,7 +71,10 @@ impl<T: Number, A: ArrayView1<T>> Distance<A> for Minkowski<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn minkowski_distance() {
|
fn minkowski_distance() {
|
||||||
let a = vec![1., 2., 3.];
|
let a = vec![1., 2., 3.];
|
||||||
|
|||||||
+4
-1
@@ -82,7 +82,10 @@ impl<T: Number + RealNumber + FloatNumber> Metrics<T> for F1<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn f1() {
|
fn f1() {
|
||||||
let y_pred: Vec<f64> = vec![0., 0., 1., 1., 1., 1.];
|
let y_pred: Vec<f64> = vec![0., 0., 1., 1., 1., 1.];
|
||||||
|
|||||||
@@ -76,7 +76,10 @@ impl<T: Number + FloatNumber> Metrics<T> for MeanAbsoluteError<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn mean_absolute_error() {
|
fn mean_absolute_error() {
|
||||||
let y_true: Vec<f64> = vec![3., -0.5, 2., 7.];
|
let y_true: Vec<f64> = vec![3., -0.5, 2., 7.];
|
||||||
|
|||||||
@@ -76,7 +76,10 @@ impl<T: Number + FloatNumber> Metrics<T> for MeanSquareError<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn mean_squared_error() {
|
fn mean_squared_error() {
|
||||||
let y_true: Vec<f64> = vec![3., -0.5, 2., 7.];
|
let y_true: Vec<f64> = vec![3., -0.5, 2., 7.];
|
||||||
|
|||||||
@@ -95,7 +95,10 @@ impl<T: RealNumber> Metrics<T> for Precision<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn precision() {
|
fn precision() {
|
||||||
let y_true: Vec<f64> = vec![0., 1., 1., 0.];
|
let y_true: Vec<f64> = vec![0., 1., 1., 0.];
|
||||||
@@ -114,7 +117,10 @@ mod tests {
|
|||||||
assert!((score3 - 0.5).abs() < 1e-8);
|
assert!((score3 - 0.5).abs() < 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn precision_multiclass() {
|
fn precision_multiclass() {
|
||||||
let y_true: Vec<f64> = vec![0., 0., 0., 1., 1., 1., 2., 2., 2.];
|
let y_true: Vec<f64> = vec![0., 0., 0., 1., 1., 1., 2., 2., 2.];
|
||||||
|
|||||||
+4
-1
@@ -81,7 +81,10 @@ impl<T: Number> Metrics<T> for R2<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn r2() {
|
fn r2() {
|
||||||
let y_true: Vec<f64> = vec![3., -0.5, 2., 7.];
|
let y_true: Vec<f64> = vec![3., -0.5, 2., 7.];
|
||||||
|
|||||||
@@ -96,7 +96,10 @@ impl<T: RealNumber> Metrics<T> for Recall<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn recall() {
|
fn recall() {
|
||||||
let y_true: Vec<f64> = vec![0., 1., 1., 0.];
|
let y_true: Vec<f64> = vec![0., 1., 1., 0.];
|
||||||
@@ -115,7 +118,10 @@ mod tests {
|
|||||||
assert!((score3 - 0.6666666666666666).abs() < 1e-8);
|
assert!((score3 - 0.6666666666666666).abs() < 1e-8);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn recall_multiclass() {
|
fn recall_multiclass() {
|
||||||
let y_true: Vec<f64> = vec![0., 0., 0., 1., 1., 1., 2., 2., 2.];
|
let y_true: Vec<f64> = vec![0., 0., 0., 1., 1., 1., 2., 2., 2.];
|
||||||
|
|||||||
@@ -159,7 +159,10 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::linalg::basic::matrix::DenseMatrix;
|
use crate::linalg::basic::matrix::DenseMatrix;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn run_kfold_return_test_indices_simple() {
|
fn run_kfold_return_test_indices_simple() {
|
||||||
let k = KFold {
|
let k = KFold {
|
||||||
@@ -175,7 +178,10 @@ mod tests {
|
|||||||
assert_eq!(test_indices[2], (22..33).collect::<Vec<usize>>());
|
assert_eq!(test_indices[2], (22..33).collect::<Vec<usize>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn run_kfold_return_test_indices_odd() {
|
fn run_kfold_return_test_indices_odd() {
|
||||||
let k = KFold {
|
let k = KFold {
|
||||||
@@ -191,7 +197,10 @@ mod tests {
|
|||||||
assert_eq!(test_indices[2], (23..34).collect::<Vec<usize>>());
|
assert_eq!(test_indices[2], (23..34).collect::<Vec<usize>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn run_kfold_return_test_mask_simple() {
|
fn run_kfold_return_test_mask_simple() {
|
||||||
let k = KFold {
|
let k = KFold {
|
||||||
@@ -218,7 +227,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn run_kfold_return_split_simple() {
|
fn run_kfold_return_split_simple() {
|
||||||
let k = KFold {
|
let k = KFold {
|
||||||
@@ -235,7 +247,10 @@ mod tests {
|
|||||||
assert_eq!(train_test_splits[1].1, (11..22).collect::<Vec<usize>>());
|
assert_eq!(train_test_splits[1].1, (11..22).collect::<Vec<usize>>());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn run_kfold_return_split_simple_shuffle() {
|
fn run_kfold_return_split_simple_shuffle() {
|
||||||
let k = KFold {
|
let k = KFold {
|
||||||
@@ -251,7 +266,10 @@ mod tests {
|
|||||||
assert_eq!(train_test_splits[1].1.len(), 11_usize);
|
assert_eq!(train_test_splits[1].1.len(), 11_usize);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn numpy_parity_test() {
|
fn numpy_parity_test() {
|
||||||
let k = KFold {
|
let k = KFold {
|
||||||
@@ -273,7 +291,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn numpy_parity_test_shuffle() {
|
fn numpy_parity_test_shuffle() {
|
||||||
let k = KFold {
|
let k = KFold {
|
||||||
|
|||||||
@@ -321,7 +321,10 @@ mod tests {
|
|||||||
use crate::neighbors::knn_regressor::{KNNRegressor, KNNRegressorParameters};
|
use crate::neighbors::knn_regressor::{KNNRegressor, KNNRegressorParameters};
|
||||||
use crate::neighbors::KNNWeightFunction;
|
use crate::neighbors::KNNWeightFunction;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn run_train_test_split() {
|
fn run_train_test_split() {
|
||||||
let n = 123;
|
let n = 123;
|
||||||
@@ -346,7 +349,10 @@ mod tests {
|
|||||||
struct BiasedParameters {}
|
struct BiasedParameters {}
|
||||||
impl NoParameters for BiasedParameters {}
|
impl NoParameters for BiasedParameters {}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cross_validate_biased() {
|
fn test_cross_validate_biased() {
|
||||||
struct BiasedEstimator {}
|
struct BiasedEstimator {}
|
||||||
@@ -412,7 +418,10 @@ mod tests {
|
|||||||
assert_eq!(0.4, results.mean_train_score());
|
assert_eq!(0.4, results.mean_train_score());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cross_validate_knn() {
|
fn test_cross_validate_knn() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -457,7 +466,10 @@ mod tests {
|
|||||||
assert!(results.mean_train_score() < results.mean_test_score());
|
assert!(results.mean_train_score() < results.mean_test_score());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_cross_val_predict_knn() {
|
fn test_cross_val_predict_knn() {
|
||||||
let x: DenseMatrix<f64> = DenseMatrix::from_2d_array(&[
|
let x: DenseMatrix<f64> = DenseMatrix::from_2d_array(&[
|
||||||
|
|||||||
@@ -496,7 +496,10 @@ mod tests {
|
|||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn run_bernoulli_naive_bayes() {
|
fn run_bernoulli_naive_bayes() {
|
||||||
// Tests that BernoulliNB when alpha=1.0 gives the same values as
|
// Tests that BernoulliNB when alpha=1.0 gives the same values as
|
||||||
@@ -551,7 +554,10 @@ mod tests {
|
|||||||
assert_eq!(y_hat, &[1]);
|
assert_eq!(y_hat, &[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn bernoulli_nb_scikit_parity() {
|
fn bernoulli_nb_scikit_parity() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -612,7 +618,10 @@ mod tests {
|
|||||||
assert_eq!(y_hat, vec!(2, 2, 0, 0, 0, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0));
|
assert_eq!(y_hat, vec!(2, 2, 0, 0, 0, 2, 1, 1, 0, 0, 0, 0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn serde() {
|
fn serde() {
|
||||||
|
|||||||
@@ -428,7 +428,10 @@ mod tests {
|
|||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn run_categorical_naive_bayes() {
|
fn run_categorical_naive_bayes() {
|
||||||
let x = DenseMatrix::<u32>::from_2d_array(&[
|
let x = DenseMatrix::<u32>::from_2d_array(&[
|
||||||
@@ -509,7 +512,10 @@ mod tests {
|
|||||||
assert_eq!(y_hat, vec![0, 1]);
|
assert_eq!(y_hat, vec![0, 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn run_categorical_naive_bayes2() {
|
fn run_categorical_naive_bayes2() {
|
||||||
let x = DenseMatrix::<u32>::from_2d_array(&[
|
let x = DenseMatrix::<u32>::from_2d_array(&[
|
||||||
@@ -535,7 +541,10 @@ mod tests {
|
|||||||
assert_eq!(y_hat, vec![0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1]);
|
assert_eq!(y_hat, vec![0, 0, 1, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn serde() {
|
fn serde() {
|
||||||
|
|||||||
@@ -372,7 +372,10 @@ mod tests {
|
|||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn run_gaussian_naive_bayes() {
|
fn run_gaussian_naive_bayes() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -409,7 +412,10 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn run_gaussian_naive_bayes_with_priors() {
|
fn run_gaussian_naive_bayes_with_priors() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -429,7 +435,10 @@ mod tests {
|
|||||||
assert_eq!(gnb.class_priors(), &priors);
|
assert_eq!(gnb.class_priors(), &priors);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn serde() {
|
fn serde() {
|
||||||
|
|||||||
@@ -403,7 +403,10 @@ mod tests {
|
|||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn run_multinomial_naive_bayes() {
|
fn run_multinomial_naive_bayes() {
|
||||||
// Tests that MultinomialNB when alpha=1.0 gives the same values as
|
// Tests that MultinomialNB when alpha=1.0 gives the same values as
|
||||||
@@ -461,7 +464,10 @@ mod tests {
|
|||||||
assert_eq!(y_hat, &[0]);
|
assert_eq!(y_hat, &[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn multinomial_nb_scikit_parity() {
|
fn multinomial_nb_scikit_parity() {
|
||||||
let x = DenseMatrix::<u32>::from_2d_array(&[
|
let x = DenseMatrix::<u32>::from_2d_array(&[
|
||||||
@@ -524,7 +530,10 @@ mod tests {
|
|||||||
assert_eq!(y_hat, vec!(2, 2, 0, 0, 0, 2, 2, 1, 0, 1, 0, 2, 0, 0, 2));
|
assert_eq!(y_hat, vec!(2, 2, 0, 0, 0, 2, 2, 1, 0, 1, 0, 2, 0, 0, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn serde() {
|
fn serde() {
|
||||||
|
|||||||
@@ -305,7 +305,10 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::linalg::basic::matrix::DenseMatrix;
|
use crate::linalg::basic::matrix::DenseMatrix;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn knn_fit_predict() {
|
fn knn_fit_predict() {
|
||||||
let x =
|
let x =
|
||||||
@@ -317,7 +320,10 @@ mod tests {
|
|||||||
assert_eq!(y.to_vec(), y_hat);
|
assert_eq!(y.to_vec(), y_hat);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn knn_fit_predict_weighted() {
|
fn knn_fit_predict_weighted() {
|
||||||
let x = DenseMatrix::from_2d_array(&[&[1.], &[2.], &[3.], &[4.], &[5.]]);
|
let x = DenseMatrix::from_2d_array(&[&[1.], &[2.], &[3.], &[4.], &[5.]]);
|
||||||
@@ -335,7 +341,10 @@ mod tests {
|
|||||||
assert_eq!(vec![3], y_hat);
|
assert_eq!(vec![3], y_hat);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn serde() {
|
fn serde() {
|
||||||
|
|||||||
@@ -289,7 +289,10 @@ mod tests {
|
|||||||
use crate::linalg::basic::matrix::DenseMatrix;
|
use crate::linalg::basic::matrix::DenseMatrix;
|
||||||
use crate::metrics::distance::Distances;
|
use crate::metrics::distance::Distances;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn knn_fit_predict_weighted() {
|
fn knn_fit_predict_weighted() {
|
||||||
let x =
|
let x =
|
||||||
@@ -313,7 +316,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn knn_fit_predict_uniform() {
|
fn knn_fit_predict_uniform() {
|
||||||
let x =
|
let x =
|
||||||
@@ -328,7 +334,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn serde() {
|
fn serde() {
|
||||||
|
|||||||
@@ -99,7 +99,10 @@ mod tests {
|
|||||||
use crate::optimization::line_search::Backtracking;
|
use crate::optimization::line_search::Backtracking;
|
||||||
use crate::optimization::FunctionOrder;
|
use crate::optimization::FunctionOrder;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn gradient_descent() {
|
fn gradient_descent() {
|
||||||
let x0 = vec![-1., 1.];
|
let x0 = vec![-1., 1.];
|
||||||
|
|||||||
@@ -278,7 +278,10 @@ mod tests {
|
|||||||
use crate::optimization::line_search::Backtracking;
|
use crate::optimization::line_search::Backtracking;
|
||||||
use crate::optimization::FunctionOrder;
|
use crate::optimization::FunctionOrder;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn lbfgs() {
|
fn lbfgs() {
|
||||||
let x0 = vec![0., 0.];
|
let x0 = vec![0., 0.];
|
||||||
|
|||||||
@@ -129,7 +129,10 @@ impl<T: Float> LineSearchMethod<T> for Backtracking<T> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn backtracking() {
|
fn backtracking() {
|
||||||
let f = |x: f64| -> f64 { x.powf(2.) + x };
|
let f = |x: f64| -> f64 { x.powf(2.) + x };
|
||||||
|
|||||||
@@ -224,7 +224,10 @@ mod tests {
|
|||||||
use crate::linalg::basic::matrix::DenseMatrix;
|
use crate::linalg::basic::matrix::DenseMatrix;
|
||||||
use crate::preprocessing::series_encoder::CategoryMapper;
|
use crate::preprocessing::series_encoder::CategoryMapper;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn adjust_idxs() {
|
fn adjust_idxs() {
|
||||||
assert_eq!(find_new_idxs(0, &[], &[]), Vec::<usize>::new());
|
assert_eq!(find_new_idxs(0, &[], &[]), Vec::<usize>::new());
|
||||||
@@ -269,7 +272,10 @@ mod tests {
|
|||||||
(orig, oh_enc)
|
(orig, oh_enc)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn hash_encode_f64_series() {
|
fn hash_encode_f64_series() {
|
||||||
let series = vec![3.0, 1.0, 2.0, 1.0];
|
let series = vec![3.0, 1.0, 2.0, 1.0];
|
||||||
@@ -280,7 +286,10 @@ mod tests {
|
|||||||
let orig_val: f64 = inv.unwrap().into();
|
let orig_val: f64 = inv.unwrap().into();
|
||||||
assert_eq!(orig_val, 2.0);
|
assert_eq!(orig_val, 2.0);
|
||||||
}
|
}
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_fit() {
|
fn test_fit() {
|
||||||
let (x, _) = build_fake_matrix();
|
let (x, _) = build_fake_matrix();
|
||||||
@@ -296,7 +305,10 @@ mod tests {
|
|||||||
assert_eq!(num_cat, vec![2, 4]);
|
assert_eq!(num_cat, vec![2, 4]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn matrix_transform_test() {
|
fn matrix_transform_test() {
|
||||||
let (x, expected_x) = build_fake_matrix();
|
let (x, expected_x) = build_fake_matrix();
|
||||||
@@ -312,7 +324,10 @@ mod tests {
|
|||||||
assert_eq!(nm, expected_x);
|
assert_eq!(nm, expected_x);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn fail_on_bad_category() {
|
fn fail_on_bad_category() {
|
||||||
let m = DenseMatrix::from_2d_array(&[
|
let m = DenseMatrix::from_2d_array(&[
|
||||||
|
|||||||
@@ -420,7 +420,10 @@ mod tests {
|
|||||||
|
|
||||||
/// Same as `fit_for_random_values` test, but using a `StandardScaler` that has been
|
/// Same as `fit_for_random_values` test, but using a `StandardScaler` that has been
|
||||||
/// serialized and deserialized.
|
/// serialized and deserialized.
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn serde_fit_for_random_values() {
|
fn serde_fit_for_random_values() {
|
||||||
|
|||||||
@@ -199,7 +199,10 @@ where
|
|||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn from_categories() {
|
fn from_categories() {
|
||||||
let fake_categories: Vec<usize> = vec![1, 2, 3, 4, 5, 3, 5, 3, 1, 2, 4];
|
let fake_categories: Vec<usize> = vec![1, 2, 3, 4, 5, 3, 5, 3, 1, 2, 4];
|
||||||
@@ -218,14 +221,20 @@ mod tests {
|
|||||||
let enc = CategoryMapper::<&str>::from_positional_category_vec(fake_category_pos);
|
let enc = CategoryMapper::<&str>::from_positional_category_vec(fake_category_pos);
|
||||||
enc
|
enc
|
||||||
}
|
}
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn ordinal_encoding() {
|
fn ordinal_encoding() {
|
||||||
let enc = build_fake_str_enc();
|
let enc = build_fake_str_enc();
|
||||||
assert_eq!(1f64, enc.get_ordinal::<f64>(&"dog").unwrap())
|
assert_eq!(1f64, enc.get_ordinal::<f64>(&"dog").unwrap())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn category_map_and_vec() {
|
fn category_map_and_vec() {
|
||||||
let category_map: HashMap<&str, usize> = vec![("background", 0), ("dog", 1), ("cat", 2)]
|
let category_map: HashMap<&str, usize> = vec![("background", 0), ("dog", 1), ("cat", 2)]
|
||||||
@@ -240,7 +249,10 @@ mod tests {
|
|||||||
assert_eq!(oh_vec, res);
|
assert_eq!(oh_vec, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn positional_categories_vec() {
|
fn positional_categories_vec() {
|
||||||
let enc = build_fake_str_enc();
|
let enc = build_fake_str_enc();
|
||||||
@@ -252,7 +264,10 @@ mod tests {
|
|||||||
assert_eq!(oh_vec, res);
|
assert_eq!(oh_vec, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn invert_label_test() {
|
fn invert_label_test() {
|
||||||
let enc = build_fake_str_enc();
|
let enc = build_fake_str_enc();
|
||||||
@@ -265,7 +280,10 @@ mod tests {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn test_many_categorys() {
|
fn test_many_categorys() {
|
||||||
let enc = build_fake_str_enc();
|
let enc = build_fake_str_enc();
|
||||||
|
|||||||
+16
-4
@@ -269,7 +269,10 @@ mod tests {
|
|||||||
use super::*;
|
use super::*;
|
||||||
use crate::svm::Kernels;
|
use crate::svm::Kernels;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn linear_kernel() {
|
fn linear_kernel() {
|
||||||
let v1 = vec![1., 2., 3.];
|
let v1 = vec![1., 2., 3.];
|
||||||
@@ -278,7 +281,10 @@ mod tests {
|
|||||||
assert_eq!(32f64, Kernels::linear().apply(&v1, &v2).unwrap());
|
assert_eq!(32f64, Kernels::linear().apply(&v1, &v2).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn rbf_kernel() {
|
fn rbf_kernel() {
|
||||||
let v1 = vec![1., 2., 3.];
|
let v1 = vec![1., 2., 3.];
|
||||||
@@ -293,7 +299,10 @@ mod tests {
|
|||||||
assert!((0.2265f64 - result) < 1e-4);
|
assert!((0.2265f64 - result) < 1e-4);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn polynomial_kernel() {
|
fn polynomial_kernel() {
|
||||||
let v1 = vec![1., 2., 3.];
|
let v1 = vec![1., 2., 3.];
|
||||||
@@ -308,7 +317,10 @@ mod tests {
|
|||||||
assert!((4913f64 - result) < std::f64::EPSILON);
|
assert!((4913f64 - result) < std::f64::EPSILON);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn sigmoid_kernel() {
|
fn sigmoid_kernel() {
|
||||||
let v1 = vec![1., 2., 3.];
|
let v1 = vec![1., 2., 3.];
|
||||||
|
|||||||
+16
-4
@@ -948,7 +948,10 @@ mod tests {
|
|||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use crate::svm::*;
|
use crate::svm::*;
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn svc_fit_predict() {
|
fn svc_fit_predict() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -996,7 +999,10 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn svc_fit_decision_function() {
|
fn svc_fit_decision_function() {
|
||||||
let x = DenseMatrix::from_2d_array(&[&[4.0, 0.0], &[0.0, 4.0], &[8.0, 0.0], &[0.0, 8.0]]);
|
let x = DenseMatrix::from_2d_array(&[&[4.0, 0.0], &[0.0, 4.0], &[8.0, 0.0], &[0.0, 8.0]]);
|
||||||
@@ -1034,7 +1040,10 @@ mod tests {
|
|||||||
assert!(num::Float::abs(y_hat[0]) <= 0.1);
|
assert!(num::Float::abs(y_hat[0]) <= 0.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn svc_fit_predict_rbf() {
|
fn svc_fit_predict_rbf() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -1083,7 +1092,10 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn svc_serde() {
|
fn svc_serde() {
|
||||||
|
|||||||
+2
-2
@@ -606,7 +606,7 @@ mod tests {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
// TODO: had to disable this test as it runs for too long
|
// TODO: had to disable this test as it runs for too long
|
||||||
// #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
// #[cfg_attr(all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test::wasm_bindgen_test)]
|
||||||
// #[test]
|
// #[test]
|
||||||
// fn svr_fit_predict() {
|
// fn svr_fit_predict() {
|
||||||
// let x = DenseMatrix::from_2d_array(&[
|
// let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -645,7 +645,7 @@ mod tests {
|
|||||||
// assert!(mean_squared_error(&y_hat, &y) < 2.5);
|
// assert!(mean_squared_error(&y_hat, &y) < 2.5);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
// #[cfg_attr(all(target_arch = "wasm32", not(target_os = "wasi")), wasm_bindgen_test::wasm_bindgen_test)]
|
||||||
// #[test]
|
// #[test]
|
||||||
// #[cfg(feature = "serde")]
|
// #[cfg(feature = "serde")]
|
||||||
// fn svr_serde() {
|
// fn svr_serde() {
|
||||||
|
|||||||
@@ -899,7 +899,10 @@ mod tests {
|
|||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn gini_impurity() {
|
fn gini_impurity() {
|
||||||
assert!(
|
assert!(
|
||||||
@@ -915,7 +918,10 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn fit_predict_iris() {
|
fn fit_predict_iris() {
|
||||||
let x: DenseMatrix<f64> = DenseMatrix::from_2d_array(&[
|
let x: DenseMatrix<f64> = DenseMatrix::from_2d_array(&[
|
||||||
@@ -968,7 +974,10 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn fit_predict_baloons() {
|
fn fit_predict_baloons() {
|
||||||
let x: DenseMatrix<f64> = DenseMatrix::from_2d_array(&[
|
let x: DenseMatrix<f64> = DenseMatrix::from_2d_array(&[
|
||||||
@@ -1003,7 +1012,10 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn serde() {
|
fn serde() {
|
||||||
|
|||||||
@@ -731,7 +731,10 @@ mod tests {
|
|||||||
assert!(iter.next().is_none());
|
assert!(iter.next().is_none());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
fn fit_longley() {
|
fn fit_longley() {
|
||||||
let x = DenseMatrix::from_2d_array(&[
|
let x = DenseMatrix::from_2d_array(&[
|
||||||
@@ -808,7 +811,10 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
#[cfg_attr(
|
||||||
|
all(target_arch = "wasm32", not(target_os = "wasi")),
|
||||||
|
wasm_bindgen_test::wasm_bindgen_test
|
||||||
|
)]
|
||||||
#[test]
|
#[test]
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
fn serde() {
|
fn serde() {
|
||||||
|
|||||||
Reference in New Issue
Block a user