feat: added support to wasm (#94)
* test: run tests also in wasm targets * fix: install rand with wasm-bindgen por wasm targets * fix: use actual usize size to access buffer. * fix: do not run functions that create files in wasm. * test: do not run in wasm test that panics. Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
This commit is contained in:
@@ -225,6 +225,7 @@ mod tests {
|
||||
use crate::linalg::naive::dense_matrix::DenseMatrix;
|
||||
use crate::preprocessing::series_encoder::CategoryMapper;
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
||||
#[test]
|
||||
fn adjust_idxs() {
|
||||
assert_eq!(find_new_idxs(0, &[], &[]), Vec::<usize>::new());
|
||||
@@ -269,6 +270,7 @@ mod tests {
|
||||
(orig, oh_enc)
|
||||
}
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
||||
#[test]
|
||||
fn hash_encode_f64_series() {
|
||||
let series = vec![3.0, 1.0, 2.0, 1.0];
|
||||
@@ -279,6 +281,7 @@ mod tests {
|
||||
let orig_val: f64 = inv.unwrap().into();
|
||||
assert_eq!(orig_val, 2.0);
|
||||
}
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
||||
#[test]
|
||||
fn test_fit() {
|
||||
let (x, _) = build_fake_matrix();
|
||||
@@ -294,6 +297,7 @@ mod tests {
|
||||
assert_eq!(num_cat, vec![2, 4]);
|
||||
}
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
||||
#[test]
|
||||
fn matrix_transform_test() {
|
||||
let (x, expected_x) = build_fake_matrix();
|
||||
@@ -309,6 +313,7 @@ mod tests {
|
||||
assert_eq!(nm, expected_x);
|
||||
}
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
||||
#[test]
|
||||
fn fail_on_bad_category() {
|
||||
let m = DenseMatrix::from_2d_array(&[
|
||||
|
||||
Reference in New Issue
Block a user