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:
@@ -88,6 +88,7 @@ mod tests {
|
||||
use crate::optimization::line_search::Backtracking;
|
||||
use crate::optimization::FunctionOrder;
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
||||
#[test]
|
||||
fn gradient_descent() {
|
||||
let x0 = DenseMatrix::row_vector_from_array(&[-1., 1.]);
|
||||
|
||||
@@ -239,6 +239,7 @@ mod tests {
|
||||
use crate::optimization::line_search::Backtracking;
|
||||
use crate::optimization::FunctionOrder;
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
||||
#[test]
|
||||
fn lbfgs() {
|
||||
let x0 = DenseMatrix::row_vector_from_array(&[0., 0.]);
|
||||
|
||||
@@ -112,6 +112,7 @@ impl<T: Float> LineSearchMethod<T> for Backtracking<T> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
|
||||
#[test]
|
||||
fn backtracking() {
|
||||
let f = |x: f64| -> f64 { x.powf(2.) + x };
|
||||
|
||||
Reference in New Issue
Block a user