File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -8,9 +8,8 @@ pub mod digits;
8
8
pub mod generator;
9
9
pub mod iris;
10
10
11
- use crate :: numbers:: basenum:: Number ;
12
11
#[ cfg( not( target_arch = "wasm32" ) ) ]
13
- use crate :: numbers:: realnum:: RealNumber ;
12
+ use crate :: numbers:: { basenum :: Number , realnum:: RealNumber } ;
14
13
#[ cfg( not( target_arch = "wasm32" ) ) ]
15
14
use std:: fs:: File ;
16
15
use std:: io;
Original file line number Diff line number Diff line change @@ -715,7 +715,7 @@ mod tests {
715
715
#[ cfg_attr( target_arch = "wasm32" , wasm_bindgen_test:: wasm_bindgen_test) ]
716
716
#[ test]
717
717
fn lr_fit_predict ( ) {
718
- let x = DenseMatrix :: from_2d_array ( & [
718
+ let x: DenseMatrix < f64 > = DenseMatrix :: from_2d_array ( & [
719
719
& [ 1. , -5. ] ,
720
720
& [ 2. , 5. ] ,
721
721
& [ 3. , -2. ] ,
@@ -739,8 +739,12 @@ mod tests {
739
739
assert_eq ! ( lr. coefficients( ) . shape( ) , ( 3 , 2 ) ) ;
740
740
assert_eq ! ( lr. intercept( ) . shape( ) , ( 3 , 1 ) ) ;
741
741
742
- assert ! ( ( * lr. coefficients( ) . get( ( 0 , 0 ) ) - 0.0435f32 ) . abs( ) < 1e-4 ) ;
743
- assert ! ( ( * lr. intercept( ) . get( ( 0 , 0 ) ) - 0.1250f32 ) . abs( ) < 1e-4 ) ;
742
+ assert ! ( ( * lr. coefficients( ) . get( ( 0 , 0 ) ) - 0.0435 ) . abs( ) < 1e-4 ) ;
743
+ assert ! (
744
+ ( * lr. intercept( ) . get( ( 0 , 0 ) ) - 0.1250 ) . abs( ) < 1e-4 ,
745
+ "expected to be least than 1e-4, got {}" ,
746
+ ( * lr. intercept( ) . get( ( 0 , 0 ) ) - 0.1250 ) . abs( )
747
+ ) ;
744
748
745
749
let y_hat = lr. predict ( & x) . unwrap ( ) ;
746
750
Original file line number Diff line number Diff line change @@ -488,6 +488,10 @@ mod tests {
488
488
& distribution. class_priors,
489
489
& vec!( 0.4666666666666667 , 0.2 , 0.3333333333333333 )
490
490
) ;
491
+
492
+ // Due to float differences in WASM32,
493
+ // we disable this test for that arch
494
+ #[ cfg( not( target_arch = "wasm32" ) ) ]
491
495
assert_eq ! (
492
496
& nb. feature_log_prob( ) [ 1 ] ,
493
497
& vec![
You can’t perform that action at this time.
0 commit comments